Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation should happen after security checks #664

Open
danielo515 opened this issue Aug 17, 2024 · 2 comments
Open

Validation should happen after security checks #664

danielo515 opened this issue Aug 17, 2024 · 2 comments

Comments

@danielo515
Copy link

Hello.
I noticed that validation always happens bo matter what. Then the security is checked and if security rails the request is rejected.
This opens a attack vector because request validation is costly compared to checking auth (specially if it is in cookies or JWT).
I tried changing the order of definition, but that makes no difference.

@AMar4enko
Copy link

AMar4enko commented Aug 19, 2024

Second this. I assume changing src/internal/serverRequestParser.ts#L49

to something along the lines below would work

 parseSecurity(endpoint).pipe(
   Effect.bindTo(`security`),
   Effect.bind(`headers`, () => parseHeaders(endpoint, parseOptions)),
   Effect.bind(`path`, () => parsePath(endpoint, parseOptions)),
   Effect.bind(`query`, () => parseQuery(endpoint, parseOptions)),
   Effect.bind(`body`, () => parseBody(endpoint, parseOptions))
 )

@AMar4enko
Copy link

Oh it appears I have a fork with said change - I'll make a PR today

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants