security: slug-validate field_name on write to close fieldId XSS sink

Aperta
#1,031 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
40/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
typescript
Ambito
frontend, security

Direzione di ricerca

Start in packages/core/src/templates/components/dynamic-field.template.ts, where fieldId and fieldName are interpolated into the id, name and onclick attributes, and look at the removeMediaFromMultiple call and the escapeJsAttr helper. Find where field_name is written to the schema or field definitions, since the issue asks for validation there. Done means field names outside [a-z0-9_-] are rejected on write and the template tests still pass. The issue does not say how to handle existing stored names, so check with maintainers before deciding that.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

area: admin bug priority: P1 security triage: needs-validation

Summary

In dynamic-field.template.ts, the onclick for multi-media remove is:

onclick="removeMediaFromMultiple('${fieldId}', '${escapeJsAttr(url)')"

fieldId derives from field.name and is interpolated without escaping. A crafted field name containing ' or " can break the JS string context → stored XSS via the schema/field-definition path.

Root fix

Slug-validate field_name on write (allow only [a-z0-9_-]). This closes the sink for all similar id/name-from-field_name sinks in the template, not just this one.

Scope

Explicitly scoped out of #1029 (which fixed the media value/url sinks). Pre-existing issue, not introduced by that PR.

Related

  • #1028 — stored XSS via media field value (fixed in #1029)
  • packages/core/src/templates/components/dynamic-field.template.ts — fieldId/fieldName interpolated into id, name, onclick attrs throughout
Lingua principale
TypeScript
Stelle
1.8k
Fork
219
Merge medio
2g 21h
PR unite (30g)
67

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di SonicJs-Org/sonicjs

Tutte le issue di SonicJs-Org/sonicjs

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.