Repository navigation
fix(subscription): sanitize uid and eliminate script injection in pricing template (#14477) - #14478
Conversation
|
Thanks @PINYOPATTANAWASANPORN — solid fix for the reflected XSS from #14477, and the regression tests are a welcome addition. Verified against head 60a9c21:
Two CI failures need a quick follow-up before merge:
One small thing worth a line in the PR description: the JS fallback append changed from Leaving for human maintainer review: it's a security fix on the payments/checkout page, so it should get maintainer sign-off before merge. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
- Strips trailing whitespace in index.html line 794. - Moves import re to module top in main.py. - Removes unused import re in test_subscription_security.py.
|
Thank you @Git-on-my-level for the thorough review and validation! Addressed all items in commit
All CI preflight and hygiene checks should now be green! |
kodjima33
left a comment
There was a problem hiding this comment.
Confirmed raw {{ uid }} interpolated into inline <script> in subscription template on main (reflected XSS), plus a real uid=/client_reference_id= param mismatch bug. Fixes #14477 with sanitization + data-attribute + tests, 5/5. Merging.
…id, add hermetic tests - Remove genuinely unused imports: Response, HTTPException, RedirectResponse, JSONResponse, datetime, quote - Preserve _sanitize_uid and all XSS protection from BasedHardware#14478 - Add hermetic test_main.py (10 tests) with self.fail() guards: - Router prefix/tags validation - Empty uid endpoint rendering - Valid uid sanitized passthrough - XSS payload rejection via _sanitize_uid - SQL injection rejection via _sanitize_uid - Register subscription-plugin-tests in checks-manifest.yaml Addresses all feedback from @Git-on-my-level review: 1. _sanitize_uid restored (never removed in this revision) 2. Tests assert sanitized output, not raw passthrough 3. self.fail() in else branches prevents silent passes 4. checks-manifest covers subscription test suite Failure-Class: none
…id, add hermetic tests - Remove genuinely unused imports: Response, HTTPException, RedirectResponse, JSONResponse, datetime, quote - Preserve _sanitize_uid and all XSS protection from BasedHardware#14478 - Add hermetic test_main.py (10 tests) with self.fail() guards: - Router prefix/tags validation - Empty uid endpoint rendering - Valid uid sanitized passthrough - XSS payload rejection via _sanitize_uid - SQL injection rejection via _sanitize_uid - Register subscription-plugin-tests in checks-manifest.yaml Addresses all feedback from @Git-on-my-level review: 1. _sanitize_uid restored (never removed in this revision) 2. Tests assert sanitized output, not raw passthrough 3. self.fail() in else branches prevents silent passes 4. checks-manifest covers subscription test suite Failure-Class: none
Summary of Changes
uidquery parameter insubscription_pageand eliminating unescaped template interpolation in inline JavaScript.uidup to 128 characters via_sanitize_uid().templates/subscription/index.htmlto store the sanitizeduidas adata-uidattribute on the container element, removing inline Jinja2 injection from<script>blocks.plugins/subscription/test_subscription_security.py.Root Cause / Technical Context
plugins/subscription/main.pyaccepted an unvalidateduidquery parameter and passed it intotemplates/subscription/index.html. The template previously interpolated{{ uid }}directly into JavaScript variables within<script>, allowing attackers to execute arbitrary JavaScript (reflected XSS) via crafted query payloads (e.g.?uid=';alert(document.domain);//).Verification & Testing
<script>, SQL-like injections, backticks, quotes).\n).Impact & Compatibility
Failure-Class: none