-
-
Notifications
You must be signed in to change notification settings - Fork 37
BUGFIX: catch InvalidHmacErrors in DefaultFormStateInitializer #180
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
Open
Pingu501
wants to merge
1
commit into
neos:5.4
Choose a base branch
from
Pingu501:ah/catch-hmac-validation-exceptions
base: 5.4
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
silently catching and ignoring exceptions is almost never a good idea. IMO we should think about other ways to solve the issue..
What is the issue? That exceptions are logged due to incorrect requests to your site? Can't you detect them otherwise?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem I try to solve is when somebody tinkers with the hmac in the form, the page will throw a 500er.
Sample: https://www.neos.io/submission-forms/service-provider-submission.html
When manipulating the
--service-provider-form[__state]in the DOM directly by replacing the value withfoobarthe submission of the form will result in a error 500er page.This attracts bots hoping to exploit this issue, resulting in thousands of requests.
I know this is not a security issue, at least I don't know how this could get exploit, but still attracts lots of attention.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the clarification! I agree that a 500 error is a problem in this case, but IMO it should not ignore the error but throw some 4** error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes you are right, the current behavior with a thrown exception is implemented in multiple functions and also tested.
Question is who should handle the
InvalidArgumentForHashGenerationExceptionandInvalidHashException.Maybe the primary issue is, that
InvalidArgumentForHashGenerationExceptiondoes not set the status code to 400, likeInvalidHashExceptiondoes?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could, in your Flow configuration, decide to ignore that kind of exceptions or handle them differently (see https://flowframework.readthedocs.io/en/stable/TheDefinitiveGuide/PartIII/ErrorAndExceptionHandling.html). Maybe that's an approach.
Otherwise the rendering part could maybe catch the exception and display a more generic error instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might fix it in a single project, but I'm more looking into a general fix solving it for every project. I think that over 90% of all cases using this package, there is no custom code around this methods.
Just had a look into our sites using this package and all suffer from bots trying to exploit this exception. Fixing it in every single project instead of fixing it at the root feels wrong to me 😅
I do believe that this exception is only triggered by bad actors, so I only care in them not seeing any exceptions. For normal users this will/should never happen and work just fine.
Maybe discuss this person to person next week? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hear you. I'm just concerned that this might hide bugs in someones custom form that creates some invalid state.
OTOH maybe it's just a theoretical issue..
So definitely no -1 from me, let's see what others have to say
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi there :)
what do you think about an additional System error Log in the catch block? Would that be verbose enough?
I also like the 400 status idea. @Pingu501 do you know, how bots or security leak detections would react to 400er responses?
cheers