Merged
Conversation
cristianrcv
approved these changes
Feb 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements comprehensive HTTP security headers middleware to protect against common browser-based attacks including SSL stripping, clickjacking, XSS, MIME-sniffing, and unauthorized feature access.
Problem Statement
The application was identified as vulnerable to multiple security risks due to missing HTTP response headers:
Vulnerability: Server Security Misconfiguration - Lack of Security Headers
OWASP Severity: Low
CVSS v3.1 Score: Low (3.7)
Missing Headers
Affected Resources
https://wave.stage-seqera.io/v1alpha1/*- Missing HSTS headerhttps://community.wave.stage-seqera.io/- Missing all security headersSolution
Implemented a global Gin middleware (
securityHeadersMiddleware) that adds six critical security headers to all HTTP responses.Security Headers Implemented
1. Strict-Transport-Security (HSTS)
2. X-Frame-Options
3. X-Content-Type-Options
4. Content-Security-Policy (CSP)
Directives:
default-src 'self': Only allow resources from same originstyle-src 'self' 'unsafe-inline': Allow inline styles (needed for Tailwind CSS)script-src 'self': Only allow scripts from same originimg-src 'self' data: https:: Allow images from same origin, data URIs, and HTTPSfont-src 'self': Only allow fonts from same originobject-src 'none': Block plugins (Flash, etc.)base-uri 'self': Prevent base tag injectionform-action 'self': Only allow form submissions to same originframe-ancestors 'none': Enhanced clickjacking protection5. Referrer-Policy
6. Permissions-Policy
Changes
Modified Files
pkg/server/server.gosecurityHeadersMiddleware()function (lines 185-221)New()function (line 88)New Files
pkg/server/security_headers_test.go(260 lines)Implementation Details
Middleware Placement
Rationale:
Test Coverage
TestSecurityHeadersMiddleware
Validates all six headers are set with correct values:
TestSecurityHeadersMiddleware_MultipleRequests
TestSecurityHeadersMiddleware_WithOtherMiddleware
TestSecurityHeadersMiddleware_HSTS_Format
TestSecurityHeadersMiddleware_CSP_Directives
Test Results
$ go test ./pkg/server/... -v === RUN TestSecurityHeadersMiddleware === RUN TestSecurityHeadersMiddleware/Strict-Transport-Security_header === RUN TestSecurityHeadersMiddleware/X-Frame-Options_header === RUN TestSecurityHeadersMiddleware/X-Content-Type-Options_header === RUN TestSecurityHeadersMiddleware/Content-Security-Policy_header === RUN TestSecurityHeadersMiddleware/Referrer-Policy_header === RUN TestSecurityHeadersMiddleware/Permissions-Policy_header --- PASS: TestSecurityHeadersMiddleware (0.00s) [...] PASS ok github.com/seqeralabs/staticreg/pkg/server 2.100sAll tests passing - No regressions introduced
Security Impact
Before
After
Verification
Manual Testing
Browser Testing
Use browser DevTools to verify:
Configuration Notes
CSP Customization
The current CSP policy allows
'unsafe-inline'for styles to support Tailwind CSS. If your application requires stricter CSP:HSTS Considerations
To enable HSTS preload:
References
Checklist
Review Focus Areas
CSP Policy (
pkg/server/server.go:207)'unsafe-inline'is acceptable for your use caseHSTS Configuration (
pkg/server/server.go:190)Middleware Order (
pkg/server/server.go:88)Test Coverage (
pkg/server/security_headers_test.go)Resolves: Server Security Misconfiguration vulnerability (OWASP Low, CVSS 3.7)
Impact: Hardens application against clickjacking, XSS, SSL stripping, and MIME-sniffing attacks