-
Notifications
You must be signed in to change notification settings - Fork 11
fix: missing Auth header returns 400 Bad Request #27
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
Conversation
|
@vietle-aws @danpilgrim-aws |
|
@larrygao001 @declanvk please take a look |
|
LGTM |
|
I reviewed the previous PR associated here. It recommended logging the missing header in case of exception. Can you please incorporate the comments from previous PR? |
aws_jupyter_proxy/awsproxy.py
Outdated
| auth_header_parts[1].split("=")[1].split("/") | ||
| ) | ||
| except (KeyError, IndexError): | ||
| raise HTTPError(400, message=f"Bad Request") |
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.
Is "Bad Request" sufficient? Does security guideline allow you to put some specific message, like, "Malformed Authorization header"?
|
|
||
| @pytest.mark.asyncio | ||
| @patch("os.getenv") | ||
| async def test_missing_authorization_header(mock_getenv, mock_session): |
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 a test case for malformed authorization header?
aws-khatria
left a comment
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.
LGTM
Commit summary:
fix: missing Authorization header returns 400 Bad Request
Description of changes:
KeyErrorandIndexErrorwhen building auth headers, and return a400 Bad Request.Why:
Currently, if an upstream request is missing an
Authorizationheader, a Python stack trace is returned in the response body. This was flagged as a potential security vulnerability. Similar to the issue fixed in #26We now catch
KeyErrorandIndexErrorwhen building upstream request auth headers. We don't expect customers to malform a request, so we deliberately return a vague error message.Verification:
python -m build.pip list.aws_jupyter_proxy, making sure that anAuthorizationheader is missing.400 Bad Requestis returned.