-
-
Notifications
You must be signed in to change notification settings - Fork 764
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
adding param of options to config of ssl_context #1692
Conversation
what vulnerability |
Check your mailbox. 🙏 I've forwarded your email @aswanidutt87 , jfyk. |
if config.ssl_options is not None: | ||
assert ssl.OP_NO_RENEGOTIATION in config.ssl_options | ||
assert ssl.OP_NO_TLSv1_2 in config.ssl_options |
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.
if config.ssl_options is not None: | |
assert ssl.OP_NO_RENEGOTIATION in config.ssl_options | |
assert ssl.OP_NO_TLSv1_2 in config.ssl_options | |
assert ssl.OP_NO_RENEGOTIATION in config.ssl_options | |
assert ssl.OP_NO_TLSv1_2 in config.ssl_options |
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.
if I dont check for None on the Optional[ssl.Options], getting mypy errors like "unsupported right operand type for in optional" as by default they are Optional list of ssl.Options type
tests/test_config.py
Outdated
config = Config( | ||
app=asgi_app, | ||
) | ||
config.load() | ||
assert not config.ssl_options |
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.
Shouldn't we check the config.ssl
created instead?
config = Config( | |
app=asgi_app, | |
) | |
config.load() | |
assert not config.ssl_options | |
config = Config(app=asgi_app) | |
config.load() | |
assert not config.ssl_options |
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.
agreed, removing this test as checking for config.ssl is True assertion test is already there- coverage is good.
uvicorn/config.py
Outdated
if self.ssl_options: | ||
for each_option in self.ssl_options: | ||
self.ssl.options |= each_option |
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 should probably be inside the create_ssl_context
function.
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.
agreed moved to create_ssl_context.
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 is slightly out of date now in terms of some of the API calls, but I think it solves a similar issue: https://github.com/OpenCTI-Platform/client-python/blob/14cbac14afe76b3003baa5fff56c72af9eb17935/pycti/connector/opencti_connector_helper.py#L77
uvicorn/main.py
Outdated
"--ssl-options", | ||
type=list, | ||
default=None, | ||
help="Options to set on ssl context", |
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.
Those are integers, right? Can we point out the options available here as well?
help="Options to set on ssl context", | |
help="Options to set on ssl context.", |
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.
added the file and Enum class to look for
@Kludex , please have a look at the changes made per your review comments, we need this change to resolve a Vulnerability |
I'll take time to review this. I need to study our options, because I know there's an issue open to add the SSL context via
I think it was explained on Gitter why this is not a vulnerability on our side, but it was also agreed this PR makes sense. |
@aswanidutt87 What do you think about doing what #806 suggests instead? i.e. passing the SSL context via uvicorn programmatically. |
@Kludex there is no option of adding ssl context to uvicorn as of now, both passing SSL context or SSL options works here, I would leave it to you which one you prefer to include. if we go with the route of adding SSL context then the usage of uvicorn should be as follows just to make it to work for every scenario in future adding a ssl_context looks more useful to be honest. we can use config.py to create our own ssl_context and we can pass it into uvicorn.run |
@Kludex, As we have tried the route with your suggestion couldnt get the custom ssl_context to pass into the server, we want to request you to kindly consider this adding of options to existing context. |
That's not how I see it. I've replied to your last message here, and you didn't reply. Please, do not send me emails regarding issues or PRs. I read all comments on this repository. |
This is related to issue #806 , we are required to resolve a vulnerability of DoS by adding the option of ssl.OP_NO_RENEGOTIATION to the ssl_context.
Currently there is no provision of adding any options to the config of ssl_context.
we have added the options list of ssl.Options type to the main.py and there by to the config.py.
Added unit tests - coverage - total as of this change - 97.69%, report attached, checks, lint ran fine.