Repository navigation
fix(proxy): add includeSubDomains to the Strict-Transport-Security header - #4116
Conversation
…ader Assisted-by: Claude Code:claude-opus-5-5
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 5 |
🟢 Coverage 100.00% diff coverage · +0.01% coverage variation
Metric Results Coverage variation ✅ +0.01% coverage variation (-1.00%) Diff coverage ✅ 100.00% diff coverage Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (a2f9b5b) 95037 29290 30.82% Head commit (b9a39ea) 95038 (+1) 29301 (+11) 30.83% (+0.01%) Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch:
<coverage of head commit> - <coverage of common ancestor commit>Diff coverage details
Coverable lines Covered lines Diff coverage Pull request (#4116) 1 1 100.00% Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified:
<covered lines added or modified>/<coverable lines added or modified> * 100%
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
pbleser-oc
left a comment
There was a problem hiding this comment.
Thanks, looks good to me. The test fails without the change, and the note in the description about subdomains still on plain HTTP is what admins need to know for the release notes.
Description
The proxy sets the
Strict-Transport-Securityheader on responses to HTTPS requests. It hadmax-ageandpreload, but notincludeSubDomains. It now sends:With
includeSubDomains, a browser that has seen the header also uses only HTTPS for all subdomains of the OpenCloud host, e.g.*.cloud.example.comforcloud.example.com. Other hosts of the same domain, such asoffice.example.com, are not affected.Nothing else changes:
Strict-Transport-Securityheader. This includes installations withPROXY_TLS=falsebehind a reverse proxy:X-Forwarded-Protois not taken into account.Related Issue
Motivation and Context
Without
includeSubDomains, HSTS only protects the OpenCloud host itself, and a subdomain can still be reached over plain HTTP. Thepreloadflag asks for inclusion in the browsers' HSTS preload list, which only accepts domains whose header also containsincludeSubDomains. The nginx example in the documentation already sends both.Note for installations that serve OpenCloud with
PROXY_TLS=truedirectly on a domain whose subdomains are still served over plain HTTP: browsers that have seen the header will only use HTTPS for those subdomains, untilmax-ageexpires.How Has This Been Tested?
TestSecurityStrictTransportSecurityinservices/proxy/pkg/middleware/security_test.go:max-age=315360000; includeSubDomains; preload. This case fails without the fix: it getsmax-age=315360000; preload.X-Forwarded-Proto: https.go test ./services/proxy/...passes, andgo test -racepasses for the middleware package.go vetreports nothing new compared withmain.gofmtandgit diff --checkare clean.golangci-lintand the acceptance tests. No acceptance test checks this header.Types of changes
Checklist:
AI assistance: Claude Code (claude-opus-5-5) wrote the first draft of the code, the tests and this description; I reviewed and adjusted them.