Skip to content
This repository has been archived by the owner on Apr 11, 2021. It is now read-only.

SSRF mitigation #16

Merged
merged 2 commits into from May 11, 2017
Merged

SSRF mitigation #16

merged 2 commits into from May 11, 2017

Conversation

TheHackerDev
Copy link
Contributor

@TheHackerDev TheHackerDev commented May 10, 2017

Overview

Mitigates a server-side request forgery (SSRF; CWE-918) security vulnerability in the application.

Vulnerability details

SSRF occurs when an attacker can make a request through your server to other external servers. It can hide the attacker's origin IP from the targeted server, allowing for attackers to better cover their tracks. This is because all requests will appear to be coming from the BeePing server, rather than the attacker. SSRF also allows an attacker to enumerate accessible systems. In this particular instance, an attacker would be able to scan internal IP addresses through the BeePing server, which would otherwise be inaccessible from the internet. The BeePing server would essentially act as a proxy between the internet and the local network. In this case, it is somewhat mitigated by the fact that http.client only allows for requests using the "http://" and "https://" protocol schemes (and not things like "file://" or "ssh://", which would be far more dangerous; these protocols could be added using a custom transport, but I won't get into that here. See https://golang.org/pkg/net/http/#Transport.RegisterProtocol if you really want to do that). However, due to the fact that any system running BeePing is open to external connections ( #9 ), any system running BeePing would be vulnerable to this attack, opening up internal web servers (on any port, due to the fact that ports can be specified in the URL format with http.client as well) to be discovered by attackers; this information can be leveraged by attackers in further network penetration efforts.

Example of successful internal IP address scan:
beeping internal ip scan

Mitigation details

Due to the nature of this application, SSRF attacks can never truly be prevented- the application is intended to make outbound requests for users. However, the effects against the organization running an instance of BeePing have been mitigated by removing the ability of a user to scan internal IPv4 and IPv6 addresses (see RFC 1918 for IPv4 and RFC 4193 for IPv6).

What's included

See the following check list from #10:

The IP could not be taken from conn, because that would have been too late, and the request would have already occurred (see #10 (comment)). Unfortunately, the nested if statements in the logic are needed, because I don't want to run the validate() method to check for an error if it hasn't been explicitly set in the command line options; otherwise, it'll incorporate more processing than is needed.

Cheers,
Aaron

Aaron Hnatiw added 2 commits May 10, 2017 15:05
…mitigate SSRF vulnerability by disallowing local IP addresses (both IPv4 and IPv6).
@TheHackerDev
Copy link
Contributor Author

Oh ya, I also included some formatting fixes as well. If you'd rather, I can issue that in another PR. But frankly, that would be a bit of a pain in the ass, so I hope you're alright with keeping them in this PR 🙂

@yanc0
Copy link
Owner

yanc0 commented May 11, 2017

Awesome ! Thank you !

I'll try the feature myself and merge it if there is no issue on my side.

Code is great and fmt is alright !

@yanc0
Copy link
Owner

yanc0 commented May 11, 2017

I've test your branch, this is perfectly fine too me.
Thank you very much, awesome work !

@yanc0 yanc0 merged commit 3e1f859 into yanc0:master May 11, 2017
@TheHackerDev
Copy link
Contributor Author

No problem, Yann! Happy to help, keep up the great work with this interesting project 😄 .

Cheers,
Aaron (insp3ctre)

@TheHackerDev TheHackerDev deleted the SSRF_Mitigation branch May 14, 2017 16:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants