Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Conversation

@sauyon
Copy link
Contributor

@sauyon sauyon commented Mar 18, 2020

Tested this on LGTM.com and it fixes all but two of the obvious false positives.

The last two are these results on caddyserver/caddy, for which the source, which I'd expect to be on line 102 of fileserver.go, is strangely not found. I'll probably do some digging into this eventually, but I thought I'd leave it here for now since it seems like this may be a bit more involved.

Copy link
Contributor

@max-schaefer max-schaefer left a comment

Choose a reason for hiding this comment

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

Great to hear you were able to reduce the false positives so drastically! I have a few comments. Also, can you please make an issue regarding the two FPs not fixed by this? (No need to tackle them right away.)

@max-schaefer
Copy link
Contributor

max-schaefer commented Mar 23, 2020

I'll do that and run a dist-compare

Just to clarify: we are still waiting for an evaluation, yes?

@sauyon
Copy link
Contributor Author

sauyon commented Mar 23, 2020

Just to clarify: we are still waiting for an evaluation, yes?

This must have failed, I'll check on it.

@sauyon
Copy link
Contributor Author

sauyon commented Mar 24, 2020

...You can send weird paths with curl, but that's out of scope for open-redirect, where the attack vector would go through an unsuspecting user clicking on a benign-looking link in their browser.

Does that mean that Location and Referer headers can both be considered safe in this context as well? I noticed that a few of the results remaining use those values.

@max-schaefer
Copy link
Contributor

Probably; see my explanation of the typical attack scenario above.

@sauyon
Copy link
Contributor Author

sauyon commented Mar 24, 2020

Ok, I'll remove those as sources.

@sauyon sauyon force-pushed the openredirect-fps branch 2 times, most recently from 4ae9ea4 to 5b9dca4 Compare March 24, 2020 20:07
@sauyon
Copy link
Contributor Author

sauyon commented Mar 24, 2020

I've added a few extra things, including something I'd forgotten to change from the LGTM version of the query.

I've decided to remove all sources from request headers, because it seems to me that those wouldn't be as attacker-controllable. I've also changed the standard library models for Header.Get and Header.Values to allow taint through instead of flagging them as unsafe by default.

An evaluation (internal link) shows that we now also fix a false positive in our default suite 🎉

@sauyon sauyon force-pushed the openredirect-fps branch from 5b9dca4 to b8c5eef Compare March 24, 2020 20:44
Copy link
Contributor

@max-schaefer max-schaefer left a comment

Choose a reason for hiding this comment

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

LGTM, modulo one small comment.

Also, since this query was already in 1.23 we should add a change note for 1.24.

@sauyon
Copy link
Contributor Author

sauyon commented Mar 25, 2020

Ok, added a change note.

Copy link
Contributor

@max-schaefer max-schaefer left a comment

Choose a reason for hiding this comment

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

One minor nit: we usually quote the query @name, not the @description, in the change notes.

| Reflected cross-site scripting (`go/reflected-xss`) | Fewer results | Untrusted input flowing into an HTTP header definition or into an `fmt.Fprintf` call with a constant prefix is no longer flagged, since it is in both cases often harmless. |
| Useless assignment to field (`go/useless-assignment-to-field`) | Fewer false positives | The query now conservatively handles fields promoted through embedded pointer types. |
| Bitwise exclusive-or used like exponentiation (`go/mistyped-exponentiation`) | Fewer false positives | The query now identifies when the value of an xor is assigned to a mask object, and excludes such results. |
| Open URL redirection based on unvalidated user input may cause redirection to malicious websiets (`go/unvalidated-url-redirection`) | Fewer false positives | The query now identifies some sources that are not attacker-controlled, and excludes results with such sources. |
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
| Open URL redirection based on unvalidated user input may cause redirection to malicious websiets (`go/unvalidated-url-redirection`) | Fewer false positives | The query now identifies some sources that are not attacker-controlled, and excludes results with such sources. |
| Open URL redirect (`go/unvalidated-url-redirection`) | Fewer false positives | The query now identifies some sources that are not attacker-controlled, and excludes results with such sources. |

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, right.

@sauyon sauyon force-pushed the openredirect-fps branch from 69c5e63 to fbc2499 Compare March 25, 2020 11:01
@max-schaefer max-schaefer merged commit 13b6138 into github:master Mar 25, 2020
@sauyon sauyon deleted the openredirect-fps branch May 13, 2020 17:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants