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

fixes #7822 - forbid HTTPS requests with no client SSL certificate #217

Closed
wants to merge 1 commit into from

Conversation

domcleal
Copy link
Contributor

@domcleal domcleal commented Oct 7, 2014

Please review as a priority, and test heavily. It seems that OpenSSL correctly refuses connections when the certificate presented isn't trusted by the CA that the server is using (note, we don't have separate client/server CAs), and the problem is only when no client cert is presented.

I can't see a way to check that relying on OpenSSL for bad verification is always solid. The closest I've found is that the socket that WEBrick sees has an OpenSSL verification result attached (http://ruby-doc.org/stdlib-1.9.3/libdoc/openssl/rdoc/OpenSSL/SSL/SSLSocket.html) but I can't see a way to get at that. In any case, it only seems to reach the smart proxy when there's either no cert or it validates and in both cases the verify_result was "OK".

Lastly, I'm looking at more tests in the 7822-ssl-verify branch which test Proxy::Launcher's https_app by spinning up the rack/WEBrick app and then make requests, but this will take more refactoring. I will probably follow up with this in another ticket, and only to develop (not 1.6 etc).

No CVE assigned yet - will add it to commit message before it's merged.

@domcleal
Copy link
Contributor Author

domcleal commented Oct 7, 2014

@witlessbird fixed the handling of different HTTPS values, thanks (domcleal@84f5b4c#commitcomment-8064426)

before do
if ['yes', 'on', '1'].include? request.env['HTTPS'].to_s
if request.env['SSL_CLIENT_CERT'].to_s.empty?
log_halt 403, "No client SSL certificate supplied"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a plan to test the cert chain here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nm, we have OpenSSL::SSL::VERIFY_PEER in the https config.

@mmoll
Copy link
Contributor

mmoll commented Oct 7, 2014

Not a really excessive test, but I'm getting the expected responses now, according to my input.

  • just curl -k -> No client SSL certificate supplied
  • curl with cert and key from another CA -> tlsv1 alert unknown ca
  • curl with cert and key from the same CA -> JSON output

@dmitri-d
Copy link
Member

dmitri-d commented Oct 8, 2014

tested, looks good.


::Sinatra::Base.helpers ::Proxy::Helpers
::Sinatra::Base.helpers ::Proxy::Log
::Sinatra::Base.before do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, although it might be a bit more readable if you used a proc here instead...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that possible? I can't get it to work..

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

::Sinatra::Base.before(&Proc.new { verify_client_cert })
def verify_client_cert
...
end

Having tried that though, I can say it doesn't make any difference in clarity whatsoever. My apologies.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hehe

@dmitri-d
Copy link
Member

dmitri-d commented Oct 8, 2014

[test]

@domcleal
Copy link
Contributor Author

domcleal commented Oct 8, 2014

The test failure looks valid, let me look into it. gem update perhaps.

@dmitri-d
Copy link
Member

dmitri-d commented Oct 8, 2014

tested with the updated filter, looks good!

@domcleal
Copy link
Contributor Author

domcleal commented Oct 8, 2014

Test failure's addressed in #218 btw.

@domcleal domcleal force-pushed the 7822-ssl-verify-only branch from 2cd292c to a49993b Compare October 8, 2014 11:50
@dmitri-d
Copy link
Member

dmitri-d commented Oct 8, 2014

[test]

@dmitri-d
Copy link
Member

dmitri-d commented Oct 8, 2014

Merged at 52f0bac. Thanks, @domcleal!

@dmitri-d dmitri-d closed this Oct 8, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants