oathkeeper icon indicating copy to clipboard operation
oathkeeper copied to clipboard

Default Rule for unmatched routes

Open adamstrawson opened this issue 2 years ago • 2 comments

Preflight checklist

Describe your problem

We run oathkeeper with Istio, and filter all inbound requests via an EnvoyFilter to oathkeeper.

Endpoints that don't have a rule result in the end user receiving a 404 status and error Requested url does not match any rules. (We can of course customise this error to be more meaningful.)

As we can't setup rules that match a URL twice, we're required to setup rules for every endpoint across our services to avoid the no rule match error.

Describe your ideal solution

The ability to create a default rule that is actioned should no other rules match.

Workarounds or alternatives

An alternative approach, but more complex, is being able to have the same URL match in multiple rules, and include a concept of rule priority.

We could than have a rule that contains a match url: <.*> that will catch all requests. And then a follow up rule of url: foo with a higher priority score.

When rules are loaded at startup, they should be ordered by priority, and highest priority wins when it comes to the match evaluation.

Version

v0.38.19-beta.1

Additional Context

No response

adamstrawson avatar Mar 31 '22 11:03 adamstrawson

Hey there, thank you for the report! Is the problem that envoy handles 404 responses differently from e.g. 401 for this endpoint?

I also think that having a default "base" rule might be a very good idea. So far we've kept out priority matching as it can be quite complicated and error prone, which is not what we usually want in security software :)

aeneasr avatar Apr 16 '22 22:04 aeneasr

You are allowed to define regex in oathkeeper rules : But you are describing an anti security pattern for API you are supposed to define oathkeeper rule updates with all new services deployments via manifest updates (with for example Oathkeeper maester). For example a very open rule allowing only options on all internal services :

authenticators:
  - handler: anonymous
  authorizer:
    handler: allow
  match:
    methods:
    - OPTIONS
    url: <https>://<.*>
  mutators:
  - handler: noop

a-manraj-pvotal avatar Jul 13 '22 08:07 a-manraj-pvotal