Skip to content

Fix: add consistent and strict http headers when serving files inside extensions#1922

Merged
netomi merged 5 commits into
mainfrom
fix-xss
Jun 23, 2026
Merged

Fix: add consistent and strict http headers when serving files inside extensions#1922
netomi merged 5 commits into
mainfrom
fix-xss

Conversation

@netomi

@netomi netomi commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Previously, when files within extensions were served from various endpoints, the content type was deduced from the file type without any explicit security measure.

This could lead to XSS attacks.

This PR does the following:

  • add strict http headers whenever a user controlled input is served directly
  • correctly set content type / disposition / cache control when uploading the the configured cloud storage provider

The following protections are added:

  • X-Content-Type-Options: nosniff to prevent browsers from guessing the content type
  • strictest possible Content-Security-Policy when serving user controlled input
  • Content-Type: text/plain for certain files whose source can be viewed (preventing rendering)
  • Content-Type: application/octet-stream for remaining files
  • Content-Disposition: attachment for files that can not be viewed to prevent inline rendering

application/json and application/xml are kept as is, to allow rendering them in the browser in a convenient way

@netomi
netomi requested a review from gnugomez June 23, 2026 09:59
@netomi netomi added the snapshot Pull requests with that label will automatically build and publish snapshot images label Jun 23, 2026
Comment thread server/src/main/java/org/eclipse/openvsx/adapter/LocalVSCodeService.java Outdated
Comment thread server/src/main/java/org/eclipse/openvsx/util/HttpHeadersUtil.java Outdated
Comment thread server/src/main/java/org/eclipse/openvsx/util/HttpHeadersUtil.java
@netomi
netomi requested a review from autumnfound June 23, 2026 12:07
@netomi
netomi merged commit 098be9a into main Jun 23, 2026
4 checks passed
@netomi
netomi deleted the fix-xss branch June 23, 2026 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

snapshot Pull requests with that label will automatically build and publish snapshot images

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants