Skip to content

fix: add clickjacking protection headers - #1195

Open
DevipriyaS17 wants to merge 1 commit into
mainfrom
clickjacking
Open

fix: add clickjacking protection headers#1195
DevipriyaS17 wants to merge 1 commit into
mainfrom
clickjacking

Conversation

@DevipriyaS17

Copy link
Copy Markdown
Contributor

Summary
This PR address by adding anti-clickjacking response headers to Console HTTP responses. The change prevents the Console UI and API endpoints from being embedded in third-party frames, reducing risk of UI redress attacks against authenticated sessions.

Issue:
The finding states Console is vulnerable to clickjacking.

Sample Output

  1. Authorize endpoint headers
curl --noproxy '*' -k -s -o /dev/null -D - -X POST 'https://127.0.0.1:8181/api/v1/authorize' \
  -H 'Content-Type: application/json' \
  -d "{\"username\":\"$USERNAME\",\"password\":\"$PASSWORD\"}" \
  | grep -Ei '^(HTTP/|x-frame-options:|content-security-policy:)'


HTTP/2 200
content-security-policy: frame-ancestors 'self'
x-frame-options: SAMEORIGIN
  1. Protected GET headers
curl --noproxy '*' -k -s -o /dev/null -D - 'https://127.0.0.1:8181/api/v1/server/features' \
  -H "Authorization: Bearer $TOKEN" \
  | grep -Ei '^(HTTP/|x-frame-options:|content-security-policy:)'


HTTP/2 200
content-security-policy: frame-ancestors 'self'
x-frame-options: SAMEORIGIN
  1. Protected POST headers
PROFILE="cjtest$(date +%s)"
curl --noproxy '*' -k -s -o /dev/null -D - -X POST 'https://127.0.0.1:8181/api/v1/admin/ieee8021xconfigs' \
  -H "Authorization: Bearer $TOKEN" \
  -H 'Content-Type: application/json' \
  -d "{\"profileName\":\"$PROFILE\",\"authenticationProtocol\":0,\"pxeTimeout\":0,\"wiredInterface\":false,\"version\":\"\"}" \
  | grep -Ei '^(HTTP/|x-frame-options:|content-security-policy:)'

HTTP/2 201
content-security-policy: frame-ancestors 'self'
x-frame-options: SAMEORIGIN

@DevipriyaS17
DevipriyaS17 requested a review from a team as a code owner August 12, 2026 09:16
@DevipriyaS17
DevipriyaS17 requested a lite review from Copilot August 12, 2026 09:16
@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 50.26%. Comparing base (1068b27) to head (11a050c).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1195      +/-   ##
==========================================
+ Coverage   49.79%   50.26%   +0.47%     
==========================================
  Files         146      146              
  Lines       13460    13466       +6     
==========================================
+ Hits         6702     6769      +67     
+ Misses       6177     6108      -69     
- Partials      581      589       +8     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds global anti-clickjacking response headers to Console’s Gin HTTP router to prevent UI/API embedding in third-party frames.

Changes:

  • Introduced a Gin middleware that sets X-Frame-Options: SAMEORIGIN and Content-Security-Policy: frame-ancestors 'self' on responses.
  • Added unit tests asserting these headers are present both for a simple route and for the /api/v1/authorize route.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
internal/controller/httpapi/router.go Adds clickjacking protection middleware and applies it globally to the router.
internal/controller/httpapi/ui_test.go Adds tests validating the middleware and router behavior sets the expected headers.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread internal/controller/httpapi/ui_test.go Outdated
Comment thread internal/controller/httpapi/router.go

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

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.

2 participants