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

Support build avatars sourced from non-GitHub URLs #1441 #1942

Merged
merged 2 commits into from
Feb 25, 2025

Conversation

sagar-pathak
Copy link
Contributor

@sagar-pathak sagar-pathak commented Feb 17, 2025

Description of proposed changes

Users will now be able to define a path to a custom avatar that is not hosted on GitHub through the config file.

Related issue(s)

Related Issue: #1441

Copy link
Member

@jameshadfield jameshadfield left a comment

Choose a reason for hiding this comment

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

The changes look ok to me and work well on the datasets I've manually adjusted.

I think React's escaping of strings is enough to prevent XSS but would appreciate 👀 from @joverlee521 and @genehack on this. And also whether to allow base64 encoded images etc, however I think we already allow these in the markdown footer, right?

@genehack
Copy link
Contributor

I think React's escaping of strings is enough to prevent XSS

From what I understand, with the way this is done (setting the src prop value via interpolation), React covers the XSS angle here. (To be clear, I did not try to inject something malicious, like a Base64-encoded hunk of JS, but I don't think that will work in an <img> element the way it would with a <a href.

And also whether to allow base64 encoded images etc, however I think we already allow these in the markdown footer, right?

I think supporting Base64-encoded images would be good; we may need to indicate something about how to do this in some docs somewhere, if we don't already?

I did leave one tweak suggestion on the PR that I think should be added, as a belt-and-suspenders check that somebody didn't stick an array or an object in the JSON instead of the expected string (the same way we check the buildUrl before the regex parsing is attempted).

@sagar-pathak
Copy link
Contributor Author

I added the check for the string and tested it with a base64 image, which works. However, I'm unsure how we will add validation for base64 images since they will be received as a string. @genehack @jameshadfield

@sagar-pathak
Copy link
Contributor Author

Any updates? @joverlee521 @genehack

@tsibley
Copy link
Member

tsibley commented Feb 24, 2025

This will allow visitor tracking by third-parties. Do we intend to allow that?

@sagar-pathak
Copy link
Contributor Author

This will allow visitor tracking by third-parties. Do we intend to allow that?

Hi @tsibley, thank you for your response. Would you mind explaining more on this? Do you mean by injecting code through the build_avatar third-parties can track visitors?

@jameshadfield
Copy link
Member

This will allow visitor tracking by third-parties.

More so than allowing outbound src images in markdown footers etc?

@tsibley
Copy link
Member

tsibley commented Feb 24, 2025

More so than allowing outbound src images in markdown footers etc?

Nope!

Do you mean by injecting code through the build_avatar third-parties can track visitors?

Not code, HTTP requests.

@sagar-pathak
Copy link
Contributor Author

Not code, HTTP requests.

Wouldn't it be the same in the URL field for maintainers? Sorry, I didn't quite understand. Could you please help me clarify?

@corneliusroemer
Copy link
Member

corneliusroemer commented Feb 25, 2025

@sagar-pathak The URL isn't loaded by default, it requires a click IIUC.

The avatar would always be loaded.

Do we have precedent for loading such resources? If so, this PR might not worsen things. However if this would be a first it would be significant.

It might even require adding a consent notice in the EU to allow the request (if it uses for tracking purposes - but we don't know the purpose so we'd sort of have to err on the side of caution)

@sagar-pathak I appreciate you suggesting this change, could you explain your use case? Maybe there are other, more privacy preserving ways to achieve the same goal.

Update: I missed that this was an issue in our issue tracker made by @huddlej

@sagar-pathak
Copy link
Contributor Author

@corneliusroemer Thanks, that makes perfect sense. I will check what best practices are there to handle such situations.

Copy link
Member

@jameshadfield jameshadfield left a comment

Choose a reason for hiding this comment

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

Thanks @sagar-pathak - much appreciated!

[cornelius] Do we have precedent for loading such resources?

Yes, we already allow (and load) images with outbound src in markdown footers & narratives.

@jameshadfield jameshadfield merged commit ebd1a8d into nextstrain:master Feb 25, 2025
1 check passed
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.

5 participants