mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-30 10:27:49 +00:00
docs(antilopay): document XSS invariant on setAttribute('content', ...)
Security reviewer flagged that the safety of injecting payment-provider verification tokens into <meta content=...> rests entirely on the use of Element.setAttribute() (plain-string attribute, browser does not parse as HTML). A future contributor switching to innerHTML or template- string concatenation into <head> would turn this hook into an XSS sink. Add a comment that calls this out explicitly so the invariant survives maintenance.
This commit is contained in:
@@ -39,6 +39,12 @@ export function useSiteVerification(): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function upsertMetaTag(name: string, content: string): void {
|
function upsertMetaTag(name: string, content: string): void {
|
||||||
|
// Security note: `setAttribute('content', value)` stores `value` as a plain
|
||||||
|
// string attribute — the browser does NOT parse it as HTML. Even if a
|
||||||
|
// compromised backend returned `</meta><script>alert(1)</script>`, it would
|
||||||
|
// be stored literally inside `content="..."` and never executed. DO NOT
|
||||||
|
// switch to `innerHTML` / string concatenation into <head> — that would
|
||||||
|
// make this an XSS sink.
|
||||||
let tag = document.head.querySelector<HTMLMetaElement>(`meta[name="${name}"]`);
|
let tag = document.head.querySelector<HTMLMetaElement>(`meta[name="${name}"]`);
|
||||||
if (!tag) {
|
if (!tag) {
|
||||||
tag = document.createElement('meta');
|
tag = document.createElement('meta');
|
||||||
|
|||||||
Reference in New Issue
Block a user