-
Notifications
You must be signed in to change notification settings - Fork 0
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
Validate user input to prevent GraphQL injection attack #2521
Conversation
@@ -39,6 +39,9 @@ def current_request | |||
|
|||
def assign_new_attributes | |||
@patron_request.assign_attributes(**new_params) | |||
# This validation prevents an injection attack in GraphQL. Ideally, this would be a model validation, | |||
# but there are other validations that require first running a GraphQL query. | |||
raise ActionController::BadRequest unless /\Aa?\d+\z/.match?(new_params[:instance_hrid]) |
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.
This regex is.. starts with an a
or a digit? We also have hrids that start with L
, or in
, and probably arbitrary now in FOLIO.
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. I've updated it include those cases as well.
@@ -39,6 +39,9 @@ def current_request | |||
|
|||
def assign_new_attributes | |||
@patron_request.assign_attributes(**new_params) | |||
# This validation prevents an injection attack in GraphQL. Ideally, this would be a model validation, | |||
# but there are other validations that require first running a GraphQL query. | |||
raise ActionController::BadRequest unless /\A(a|L|in)?\d+\z/.match?(new_params[:instance_hrid]) |
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'm pretty -0 on this. I don't know that we'll be informed when new prefixes are used in FOLIO (and, like I said in my initial comment, I believe they can be arbitrary.)
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.
How about \w+? It seems bad for people to be injecting quotes, etc.
Obsoleted by #2524 |
Fixes #2520