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

Script tag in Footer Text breaks window.preloadData at Status Page #2186

Closed
2 tasks done
siimots opened this issue Oct 6, 2022 · 1 comment
Closed
2 tasks done

Script tag in Footer Text breaks window.preloadData at Status Page #2186

siimots opened this issue Oct 6, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@siimots
Copy link
Contributor

siimots commented Oct 6, 2022

⚠️ Please verify that this bug has NOT been raised before.

  • I checked and didn't find similar issue

🛡️ Security Policy

Description

Script tag in custom footer text breaks window.preloadData and it gets added to page.
footer bug

Also side effect is that you can load custom JS/XSS there if use this footer text:
"</script><script>alert()</script>"

👟 Reproduction steps

  1. Edit Status Page
  2. Footer text: <script></script>
  3. Save and json is added to top of the page.
  4. Console error: Uncaught SyntaxError: Invalid or unexpected token

👀 Expected behavior

window.preloadData should escape script to avoid parse error

😓 Actual Behavior

window.preloadData crashes when script tag is in Footer Text.

🐻 Uptime-Kuma Version

1.18.0

💻 Operating System and Arch

Windows 10

🌐 Browser

Edge latest

🐋 Docker Version

No response

🟩 NodeJS Version

No response

📝 Relevant log output

No response

@siimots siimots added the bug Something isn't working label Oct 6, 2022
@siimots siimots changed the title Script tag in Tooter Text breaks window.preloadData Script tag in Footer Text breaks window.preloadData Oct 6, 2022
@siimots siimots changed the title Script tag in Footer Text breaks window.preloadData Script tag in Footer Text breaks window.preloadData at Status Page Oct 6, 2022
@louislam
Copy link
Owner

louislam commented Oct 6, 2022

window.preloadData did parse to an JSON object.
The real problem is that, cheerio removed the end tag unexpectedly.

Oh no, just spent some time on it. In the past, I always think JSON.stringify is the best way to escape. Turned out it is not. It is more complex than I thought.

https://www.man42.net/blog/2016/12/safely-escape-user-data-in-a-script-tag/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants