Skip to content

fix: Add X-Frame-Options and CSP headers to Swagger UI endpoints#26521

Open
rohansood10 wants to merge 2 commits intoargoproj:masterfrom
rohansood10:fix/22877-x-frame-options
Open

fix: Add X-Frame-Options and CSP headers to Swagger UI endpoints#26521
rohansood10 wants to merge 2 commits intoargoproj:masterfrom
rohansood10:fix/22877-x-frame-options

Conversation

@rohansood10
Copy link

Fixes #22877

The Swagger UI endpoints (/swagger-ui and /swagger.json) don't set any framing headers, leaving them open to clickjacking via iframe embedding on malicious sites.

This adds X-Frame-Options: DENY and Content-Security-Policy: frame-ancestors 'none' to both endpoints. Both headers are set for defense-in-depth — X-Frame-Options for legacy browser support, CSP for modern browsers.

Includes test assertions for the new headers.

@rohansood10 rohansood10 requested a review from a team as a code owner February 19, 2026 10:46
@bunnyshell
Copy link

bunnyshell bot commented Feb 19, 2026

✅ Preview Environment deployed on Bunnyshell

Component Endpoints
argocd https://argocd-nbbpdk.bunnyenv.com/
argocd-ttyd https://argocd-web-cli-nbbpdk.bunnyenv.com/

See: Environment Details | Pipeline Logs

Available commands (reply to this comment):

  • 🔴 /bns:stop to stop the environment
  • 🚀 /bns:deploy to redeploy the environment
  • /bns:delete to remove the environment

Adds X-Frame-Options: DENY and Content-Security-Policy: frame-ancestors 'none'
headers to both the Swagger JSON endpoint and the Swagger UI page to prevent
clickjacking attacks via iframe embedding.

Fixes argoproj#22877

Signed-off-by: rohansood10 <rohansood10@users.noreply.github.com>
@rohansood10 rohansood10 force-pushed the fix/22877-x-frame-options branch from d60a6e3 to 40630b6 Compare February 19, 2026 10:48
Signed-off-by: rohansood10 <rohansood10@users.noreply.github.com>
@codecov
Copy link

codecov bot commented Feb 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.85%. Comparing base (9851b84) to head (69658b4).

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #26521      +/-   ##
==========================================
+ Coverage   62.82%   62.85%   +0.03%     
==========================================
  Files         412      412              
  Lines       55635    55643       +8     
==========================================
+ Hits        34951    34973      +22     
+ Misses      17352    17342      -10     
+ Partials     3332     3328       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add X-Frame-Options header to Swagger UI to prevent clickjacking

1 participant

Comments