-
Notifications
You must be signed in to change notification settings - Fork 30
server: changes from external security review #89
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
Conversation
Signed-off-by: Benson Wong <benson@tailscale.com>
In serveAuthorize there was a chance an authorization code is saved but never used if a url.Parse() fails. This commit moves the parsing logic above the saving logic. Signed-off-by: Benson Wong <benson@tailscale.com>
Signed-off-by: Benson Wong <benson@tailscale.com>
Signed-off-by: Benson Wong <benson@tailscale.com>
The UI form endpoints and the /client/ endpoints accept POST requests for modifying OAuth client data. This commit adds checking of the Sec-Fetch-Site and Origin request headers. Signed-off-by: Benson Wong <benson@tailscale.com>
add isDangerousScheme() to disallow various schemes that may be dangerous in an OAuth redirect_uri Signed-off-by: Benson Wong <benson@tailscale.com>
Signed-off-by: Benson Wong <benson@tailscale.com>
Eliminiate a low risk scenario where a refresh token could be used to issue multiple access tokens in a race condition. The trade-off is that a users would need to re-authenticate when a token refresh fails. Signed-off-by: Benson Wong <benson@tailscale.com>
Signed-off-by: Benson Wong <benson@tailscale.com>
8a8ea35 to
28c2f76
Compare
Signed-off-by: Benson Wong <benson@tailscale.com>
28c2f76 to
7c49993
Compare
| } | ||
| } | ||
|
|
||
| func TestDynamicClientRegistrationCORSHeaders(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add CORS pre-flight tests to enforce the contract we have for now. We can tighten them up in the future. DCR doesn't really work without more permissive settings, particularly with the mcp-inspector.
| } | ||
| } | ||
|
|
||
| func TestClientApiCSRF(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add tests to ensure the /clients/ api handles CSRF mitigation as expected.
|
|
||
| // isFunnelRequest checks if the request is coming through Tailscale Funnel | ||
| // Migrated from legacy/tsidp.go:2392-2410 | ||
| func isFunnelRequest(r *http.Request) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function moved to server.go
| } | ||
| } | ||
| } | ||
| func TestMetadataCORSHeaders(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add test to ensure metadata endpoints have the appropriate CORS preflight behaviour.
| } | ||
|
|
||
| // isFunnelRequest checks if the request is coming through Tailscale Funnel | ||
| func isFunnelRequest(r *http.Request) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved here from oauth-metadata.go. No changes to the code.
|
|
||
| RUN addgroup -g 1001 -S app && \ | ||
| adduser -u 1001 -S app | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
run binary as a less privileged user than root
Signed-off-by: Benson Wong <benson@tailscale.com>
Signed-off-by: Benson Wong <benson@tailscale.com>
9382158 to
f2206b2
Compare
awly
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some other stuff that would be good to patch, here or in a separate PR:
- LT-APP25-11: I don't think all endpoints do request method filtering (like
handleUI); perhaps usinghttp.ServeMuxcapabilities is the simplest thing here? https://pkg.go.dev/net/http#hdr-Patterns-ServeMux - LT-APP25-16: other misc security headers like HSTS and CSP
cab732d to
a92591c
Compare
Co-authored-by: Andrew Lytvynov <awly@tailscale.com> Signed-off-by: Benson Wong <benson@tailscale.com>
Co-authored-by: Andrew Lytvynov <awly@tailscale.com> Signed-off-by: Benson Wong <benson@tailscale.com>
- add "s" to misspelled CORS header Access-Control-Allow-Method - use filippo.io/csrf for CSRF protection Signed-off-by: Benson Wong <benson@tailscale.com>
a92591c to
986bd68
Compare
Signed-off-by: Benson Wong <benson@tailscale.com>
|
@awly thanks for the suggestions. Ready for another review. |
server/server.go
Outdated
| protect := csrf.New() | ||
| protect.AddTrustedOrigin(s.serverURL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: move this to the bottom, right before the return where it's actually needed
Signed-off-by: Benson Wong <benson@tailscale.com>
This PR incorporates the changes and recommendations from the external security review. Where applicable commits will reference the ID in the security report.