Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Insecure Image proxy #582

Open
phit opened this issue Jul 21, 2018 · 1 comment
Open

Insecure Image proxy #582

phit opened this issue Jul 21, 2018 · 1 comment

Comments

@phit
Copy link

phit commented Jul 21, 2018

repro:

  • embed an image hosted via http on ore

currently: image will simply not be rendered on ore and stripped from the page, on the forum post you will get a mixed content warning due to http resources on a https page

expected: insecure images should be passed through a proxy like camo for all user hosted content https://github.com/atmos/camo

fyi this also leads to bypassing discourses build in image proxy, which would usually avoid mixed content on the forums

@lol768
Copy link
Contributor

lol768 commented Jul 28, 2018

This should be implemented for sure, but it's difficult to do securely. Using something established like camo is probably best, but regardless of how this is implemented ensure that:

  • The resolved IP is checked to ensure it is a publicly routable IP (i.e. doesn't fall into loopback range or private address spaces).
  • This should work with both v4 and v6 addresses.
    • Be sure that IPv4-mapped IPv6 addresses are correctly handled.
  • The system needs to make 100% sure that the resolved IP is the same one that will be used to fetch the image - consider round-robin DNS scenarios where multiple A/AAAA records exist.
  • If redirects (via the Location header) are followed, the above needs to be rechecked. Might be easier to ignore redirects.
  • Only whitelisted MIME types are allowed to be fetched, only whitelisted MIME types should ever be returned in a response. Examples: image/png, image/jpeg
    • Be careful with svg that you haven't opened up a CSP bypass in the event of being able to insert a <script> (in other words make sure the image proxy is not whitelisted in script-src).
  • Images should be served with X-Content-Type-Options=nosniff for dumb browsers.
  • CSP header should be updated to only whitelist the image proxy.
  • For extra security, consider using a separate domain to serve these images.

Deploying this can also help to prevent Ore being used as a conduit for carrying out CSRF attacks.

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

No branches or pull requests

3 participants