Skip to content

Go: Partial URLs should not sanitize against SSRF#10026

Merged
owen-mc merged 5 commits intogithub:mainfrom
pwntester:patch-2
Apr 14, 2023
Merged

Go: Partial URLs should not sanitize against SSRF#10026
owen-mc merged 5 commits intogithub:mainfrom
pwntester:patch-2

Conversation

@pwntester
Copy link
Contributor

As an example:

	urlPath := ctx.Req.URL.Path
	hash := urlPath[strings.LastIndex(urlPath, "/")+1:]
        req, _ := http.NewRequest("GET", source+hash, nil)

@pwntester pwntester requested a review from a team as a code owner August 11, 2022 14:43
@github-actions github-actions bot added the Go label Aug 11, 2022
@owen-mc
Copy link
Contributor

owen-mc commented Apr 5, 2023

@pwntester Sorry this PR didn't get more attention. I've fixed up the formatting problem that was stopping CI from running properly (though it did take 3 attempts). Do you think this should be merged? Could you add a test, possibly based on the code you put in the PR description? Also, I find it confusing that the title says "should not sanitize" but the change adds a sanitizer.

@atorralba atorralba changed the title Partial URLs should not sanitize against SSRF Go: Partial URLs should not sanitize against SSRF Apr 13, 2023
@atorralba
Copy link
Contributor

@owen-mc As I understand it, this is adding a sanitizer to SafeUrlFlow, which is used to discard sinks considered "safe" in the SSRF query. Safe sinks are those that have flow coming from a part of a request that is not user-controllable (e.g. the host or full URL, since those are determined by the destination server that hosts the application, and thus can't be arbitrarily set by an attacker). In other words, adding a sanitizer to SafeUrlFlow is removing a "sanitizer" from the SSRF query.

In this case, @pwntester wants to mark flows coming from a part of the request URL as unsafe. So, for an incoming request like:

https://application.server.safe.com/path?can=be&user=controlled#this-too

The scheme, authority, and possibly path of the URL can't be arbitrarily set, so they are sources of SafeUrlFlow. On the contrary, the query and fragment parts of the URL are user-controllable, so slice accesses on the full URL path can be considered sanitizers of SafeUrlFlow.

@pwntester or anyone, please correct me if I'm wrong, since this is my first time looking at the Go SSRF query and libraries 😄.

@pwntester
Copy link
Contributor Author

Thanks @atorralba (could not have explained it better with my own words 😄)

Alvaro Muñoz and others added 5 commits April 14, 2023 12:00
As an example:

```go
	urlPath := ctx.Req.URL.Path
	hash := urlPath[strings.LastIndex(urlPath, "/")+1:]
        req, _ := http.NewRequest("GET", source+hash, nil)
```
@owen-mc owen-mc merged commit 8a4ca7f into github:main Apr 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments