• Martin Probst's avatar
    xsrftoken: panic for unsafe zero length keys · 0819898f
    Martin Probst authored
    Passing a zero length key (or secret) gives no safety against XSRF
    attacks. This is a relatively easy mistake to make, e.g. by passing
    `make([]byte, 0, 1024)` to `rand.Read` instead of `make([]byte, 1024)`,
    and currently fails open, silently.
    
    This uses panic, as the API does not allow returning a structured error,
    and catching this programming error is not worth breaking API
    compatibility. Passing a zero length secret is also not an error
    condition that API callers would handle, so there is little value in
    returning a proper error.
    
    Change-Id: Ib6457347675872188d51d2a220eee4b67900f79e
    Reviewed-on: https://go-review.googlesource.com/42411Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
    Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    0819898f
Name
Last commit
Last update
bpf Loading commit data...
context Loading commit data...
dict Loading commit data...
dns/dnsmessage Loading commit data...
html Loading commit data...
http2 Loading commit data...
icmp Loading commit data...
idna Loading commit data...
internal Loading commit data...
ipv4 Loading commit data...
ipv6 Loading commit data...
lex/httplex Loading commit data...
lif Loading commit data...
nettest Loading commit data...
netutil Loading commit data...
proxy Loading commit data...
publicsuffix Loading commit data...
route Loading commit data...
trace Loading commit data...
webdav Loading commit data...
websocket Loading commit data...
xsrftoken Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
AUTHORS Loading commit data...
CONTRIBUTING.md Loading commit data...
CONTRIBUTORS Loading commit data...
LICENSE Loading commit data...
PATENTS Loading commit data...
README Loading commit data...
codereview.cfg Loading commit data...