-
Notifications
You must be signed in to change notification settings - Fork 399
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
contribs/gnodev/pkg/emitter: use html/template not text/template to avoid any HTML serving issues or future unescaped XSS attacks: minor #3544
Labels
🐞 bug
Something isn't working
Comments
odeke-em
added a commit
to odeke-em/gno
that referenced
this issue
Jan 19, 2025
…plate for HTML generation This change uses html/template instead of text/template for HTML generation and also locks in tests to detect such subtle regressions and thus help prevent future cross-side scripting (XSS) attacks if later the scripts evolve and take in user input. Fixes gnolang#3544
odeke-em
added a commit
to odeke-em/gno
that referenced
this issue
Jan 19, 2025
… for HTML generation This change uses html/template instead of text/template for HTML generation and also locks in tests to detect such subtle regressions and thus help prevent future cross-side scripting (XSS) attacks if later the scripts evolve and take in user input. Fixes gnolang#3544
odeke-em
added a commit
to odeke-em/gno
that referenced
this issue
Jan 19, 2025
… for HTML generation This change uses html/template instead of text/template for HTML generation and also locks in tests to detect such subtle regressions and thus help prevent future cross-side scripting (XSS) attacks if later the scripts evolve and take in user input. Fixes gnolang#3544
odeke-em
added a commit
to odeke-em/gno
that referenced
this issue
Jan 19, 2025
… for HTML generation This change uses html/template instead of text/template for HTML generation and also locks in tests to detect such subtle regressions and thus help prevent future cross-side scripting (XSS) attacks if later the scripts evolve and take in user input. Fixes gnolang#3544
odeke-em
added a commit
to odeke-em/gno
that referenced
this issue
Jan 19, 2025
… for HTML generation This change uses html/template instead of text/template for HTML generation and also locks in tests to detect such subtle regressions and thus help prevent future cross-side scripting (XSS) attacks if later the scripts evolve and take in user input. Fixes gnolang#3544
odeke-em
added a commit
to odeke-em/gno
that referenced
this issue
Jan 19, 2025
… for HTML generation This change uses html/template instead of text/template for HTML generation and also locks in tests to detect such subtle regressions and thus help prevent future cross-side scripting (XSS) attacks if later the scripts evolve and take in user input. Fixes gnolang#3544
odeke-em
added a commit
to odeke-em/gno
that referenced
this issue
Jan 20, 2025
… for HTML generation This change uses html/template instead of text/template for HTML generation and also locks in tests to detect such subtle regressions and thus help prevent future cross-side scripting (XSS) attacks if later the scripts evolve and take in user input. Fixes gnolang#3544
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a currently minor issue given that the code inside middleware.go is not attacker controlled but really when starting up a server
gno/contribs/gnodev/pkg/emitter/middleware.go
Line 24 in d2813f8
gno/contribs/gnodev/pkg/emitter/middleware.go
Lines 86 to 89 in d2813f8
but it is best practice to using html/template not text/template for any HTML related code. Cross site scripting (XSS) attacks occur when injected code is not correctly escaped and I gave a proof of concept for the dangers of using text/template instead of html/template at https://cyber.orijtech.com/advisory/go-xss-concat-text-template
Exhibit
If an attacker ever got a hold of .RemoteAddr before it was generated or if the scripts evolved to later allow user input here is an exhibit of how text/template can go awry https://go.dev/play/p/dTAacWXE9uC
which when ran produces
of which the first one uses text/template and will get your pwned as I can now inject arbitrary code and as a proof of concept will pop up an alert telling you
pwned
but the imagination can go wild with what you could dobut the html/template code rightfully caught the problem and produced
which will fail to connect entirely.
The text was updated successfully, but these errors were encountered: