Skip to content

Improve image handling in markdown statements #318

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

Merged
merged 2 commits into from
May 21, 2025

Conversation

gkreitz
Copy link
Contributor

@gkreitz gkreitz commented May 19, 2025

  • Support images in subdirectories (statement/img/foo.png linked as img/foo.png)
  • Add more security-focused checks on what img src tags we allow

Thanks to @Matistjati for finding these errors

gkreitz added 2 commits May 19, 2025 11:13
Support images in subdirectories (statement/img/foo.png linked as img/foo.png)
Add more security-focused checks on what img_src we allow
@pehrsoderman pehrsoderman merged commit 6d43e60 into Kattis:develop May 21, 2025
4 checks passed
@@ -1,3 +1,3 @@
Make web request via image

<img src="http:picsum.photos/400">
<img src="https:open.kattis.com/images/site/header/logo-empty.png">
Copy link
Member

Choose a reason for hiding this comment

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

What's up with the lack of // here?

Copy link
Contributor Author

@gkreitz gkreitz Jun 1, 2025

Choose a reason for hiding this comment

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

This tests for a (mild) vulnerability that existed previously where a markdown statement could link to an external image (per the text two lines above). The link https:open.kattis.com/images/site/header/logo-empty.png will be interpreted by a browser as a normal https link, as if the // was there. However, it's also a valid relative path on a unix system, and that files exists in a subdirectory to this file.

We want to make sure images are all contained in problem packages and that the rendered markdown does not allow images to be loaded external sites (even if the problem packager is malicious and drops a suitably named file).

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.

3 participants