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

Bugfix/secure hg hook callback #1411

Closed
wants to merge 5 commits into from
Closed

Conversation

sdorra
Copy link
Member

@sdorra sdorra commented Nov 5, 2020

Proposed changes

The HgHookManager tries to find the URL of the SCM-Manager instance on the first mercurial write request.
This is necessary because it is not always as easy as http://localhost:8080 due to different environments and configurations.
Among other things, the URL is taken from the request headers Host or X-Forwarded-Host. Theoretically an attacker could send one of these headers with a request to manipulate the HgHookManager to send the ping request to a server of the attacker. If this server responds as expected by the HgHookManager, the SCM Manager sends all Mercurial Hook data to the attacker's server from that point on.

To close the gap the HgHookManager send now a temporary challenge with the ping request and the callback servlets answers with a signature of this challenge. With this answer the HgHookManager is able to verify the signature and can now trust that the instance it SCM-Manager.

Furthermore if the HgHookManager could not find a valid Hook URL, SCM-Manager does not allow any mercurial push anymore. Because otherwise it is possible to bypass security relevant mechanisms e.g: BranchWP).

Your checklist for this pull request

  • PR is well described
  • Related issues linked to PR if existing and labels set
  • Target branch is not master (in most cases develop should bet the target of choice)
  • Code does not conflict with target branch
  • New code is covered with unit tests
  • CHANGELOG.md updated

Checklist for branch merge request (not required for forks)

The issue javasecurity:S5144 which was claimed by SonarQube is now fixed.
But SonarQube will find still find the issue, because we will send the request with user controller data, but we have now a secure check if the host is SCM-Manager.
So the issue javasecurity:S5144 is now a false-positive and will be suppressed.
@sdorra sdorra added the bug Something isn't working label Nov 5, 2020
@sdorra sdorra force-pushed the bugfix/secure_hg_hook_callback branch from 3db9fef to 2ce402f Compare November 5, 2020 13:41
@sdorra sdorra force-pushed the bugfix/secure_hg_hook_callback branch from 2ce402f to 87e1476 Compare November 5, 2020 13:42
@sonarcloud
Copy link

sonarcloud bot commented Nov 5, 2020

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

36.7% 36.7% Coverage
0.0% 0.0% Duplication

@pfeuffer
Copy link
Member

pfeuffer commented Nov 6, 2020

After internal considerations we came to the conclusion, that the changes from this pull do not really fix the problem of possible "man in the middle" attacks. Therefore this will be replaced by another approach where we want to replace the complete http communication with a simple socket connection with an arbitrary port on localhost.

@pfeuffer pfeuffer closed this Nov 6, 2020
@pfeuffer pfeuffer added the invalid This doesn't seem right label Nov 6, 2020
@pfeuffer pfeuffer deleted the bugfix/secure_hg_hook_callback branch November 6, 2020 07:06
@sdorra sdorra mentioned this pull request Nov 10, 2020
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working invalid This doesn't seem right
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants