Skip to content

fix: allow GitHub avatar hosts in CSP img-src (issue #1875) - #1909

Merged
komalharshita merged 1 commit into
komalharshita:mainfrom
ionfwsrijan:fix/1875-csp-avatar-imgsrc
Aug 16, 2026
Merged

fix: allow GitHub avatar hosts in CSP img-src (issue #1875)#1909
komalharshita merged 1 commit into
komalharshita:mainfrom
ionfwsrijan:fix/1875-csp-avatar-imgsrc

Conversation

@ionfwsrijan

Copy link
Copy Markdown
Contributor

Problem

GitHub avatar images on the profile page were blocked by the site's Content-Security-Policy. The CSP set img-src 'self' data:, but profile.html renders {{ user.avatar_url }}, which is https://avatars.githubusercontent.com/... for GitHub-authenticated users, so the avatar never loaded.

Fix

Added the GitHub avatar hosts to img-src in the CSP header (src/app.py):

img-src 'self' data: https://avatars.githubusercontent.com https://*.githubusercontent.com;

The https://*.githubusercontent.com wildcard also covers related avatar/CDN subdomains used by GitHub-hosted content.

Files changed

  • src/app.py — whitelist GitHub avatar hosts in img-src.
  • tests/test_basic.py — new test_csp_allows_github_avatars asserting the CSP img-src directive includes both GitHub avatar hosts alongside 'self' and data:.

Testing

  • Verified the generated img-src directive contains 'self', data:, https://avatars.githubusercontent.com, and https://*.githubusercontent.com.
  • py_compile passes on src/app.py.

Closes #1875

@vercel

vercel Bot commented Aug 11, 2026

Copy link
Copy Markdown

@ionfwsrijan is attempting to deploy a commit to the komalsony234-1530's projects Team on Vercel.

A member of the Team first needs to authorize it.

Comment thread tests/test_basic.py
for part in csp.split(";")
if part.strip().startswith("img-src ")
)
assert "https://avatars.githubusercontent.com" in img_src
@komalharshita
komalharshita merged commit 574fe52 into komalharshita:main Aug 16, 2026
3 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: CSP img-src 'self' data: blocks GitHub avatars on the profile page

3 participants