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

Disallow crlf headers #92 #359

Closed
wants to merge 3 commits into from

Conversation

ocramz
Copy link
Collaborator

@ocramz ocramz commented Dec 16, 2023

  • add setHeader1, addHeader1
  • deprecate setHeader, addHeader , setCookie, setSimpleCookie
  • add setCookie1, setSimpleCookie1
  • add tests that demonstrate the potential vulnerability

Breaking:

  • setCookie uses setHeader rather than addHeader (as it should)

closes #92 (I was tempted to leave this ticket open until March 22 next year so we can celebrate its 10th birthday..)

@ocramz ocramz requested a review from fumieval December 16, 2023 16:55
@ocramz ocramz mentioned this pull request Dec 16, 2023
7 tasks
@ocramz ocramz self-assigned this Dec 17, 2023
@fumieval
Copy link
Collaborator

fumieval commented Dec 18, 2023

I don't think this is the right direction; setting a response header is the server's responsibility. If one accidentally puts CR or LF in the header, it's the developer's fault. The main problem with this approach is that it would not reveal the fault because it silently discards anything after CR/LF. Also, if one wants to include any user-supplied string in the response header, they should be really cautious; the risk it imposes is not specific to CR/LF.

Instead, I suggest validating the header inside changeHeader and throw 500 (via ScottyException) if it contains CR/LF/NUL. For the sake of compatibility or performance optimisation, we could make this behaviour toggleble by adding a boolean field to Options.

@ocramz
Copy link
Collaborator Author

ocramz commented Dec 19, 2023

Thank you @fumieval for the review! Good analysis, I agree with your arguments. I will revoke this PR and go back to the drawing board :)

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

Successfully merging this pull request may close these issues.

Disallow \r\n in Header text
2 participants