Security Model

Executive Summary

RHEA implements defense-in-depth security through Content Security Policy (CSP) enforcement, HTML sanitization via a shared sanitizer and DOMPurify, dependency vulnerability scanning via Renovate, and strict inline script control via nonce-based CSP. The security model covers the CDN edge, application layer, content layer, and supply chain.

Security Layers

Layer Control Description
CDN Edge AEM Edge Delivery CDN TLS termination, DDoS protection, edge caching, geographic distribution
Content Security Policy head.html CSP header Strict script and resource loading policy
HTML Sanitization sanitize.js + DOMPurify XSS prevention for authored and fetched content
Dependency Management Renovate + npm audit Automated dependency updates and vulnerability detection
Access Control GitHub + AEM IAM Repository access, authoring permissions

Content Security Policy

RHEA enforces a strict CSP defined in head.html:

script-src 'nonce-aem' 'strict-dynamic' 'unsafe-inline' http: https:;
base-uri 'self';
object-src 'none';

CSP Directives

Directive Value Purpose
script-src 'nonce-aem' 'strict-dynamic' Only scripts with the aem nonce or loaded by trusted scripts are executed
script-src 'unsafe-inline' Fallback for browsers that don't support nonce (ignored when nonce is present)
script-src http: https: Fallback for browsers that don't support 'strict-dynamic' (ignored when strict-dynamic is present)
base-uri 'self' Prevents base tag injection attacks
object-src 'none' Blocks all plugin content (Flash, Java applets)
The 'strict-dynamic' directive means that any script loaded by a nonce-trusted script is automatically trusted. This enables dynamic script loading (e.g., loadScript() in aem.js) while maintaining CSP protection.

FOUC Prevention Script

The inline theme-detection script in head.html runs with the aem nonce, making it the trust anchor for all subsequent script loading.

HTML Sanitization

RHEA uses two sanitizers at different points. They are complementary, not alternatives — see ADR-005.

Tool Used in Purpose
scripts/utilities/sanitize.js footer, header, search, cookie-consent-banner, api-widget, isi Removes the sink: inserts DOM nodes instead of assigning a string
DOMPurify (scripts/dompurify.min.js) isi, embed, scripts/editor-support.js Sanitizes a string at the boundary, where content arrives

isi uses both: DOMPurify cleans fragment content as it is read, then setSanitizedHTML inserts it without an innerHTML assignment.

Sanitization Pattern

import { setSanitizedHTML, sanitizeToFragment } from '../../scripts/utilities/sanitize.js';

// Insert authored or fetched content -- no innerHTML sink at the call site
setSanitizedHTML(element, rawHTML);

// Or, when you need nodes rather than a string
element.append(sanitizeToFragment(rawHTML));
Do not sanitize into `innerHTML`

element.innerHTML = DOMPurify.sanitize(html) was the previous pattern and is no longer correct. Sanitizing into a sink still leaves the sink: Snyk's taint analysis reports the assignment regardless, and — more importantly — a later edit can drop the sanitizer while the assignment survives. Removing the assignment removes that failure mode entirely.

All 14 DOM XSS findings were resolved this way, taking snyk code test to 0. See ADR-012.

Which to reach for
  • Inserting authored or fetched content into the DOM -> setSanitizedHTML / sanitizeToFragment
  • Cleaning a string where it arrives, in a block that already uses DOMPurify -> keep DOMPurify
  • Interpolating into a quoted attribute -> escapeHTML (escapes both quote characters)
  • Do not add a third sanitizer. api-widget keeps a local allow-list sanitizer and a quote-preserving escapeText for documented reasons — see ADR-013.

Regression coverage

tests/blocks/xss.spec.js in the RHEA repo pins every sanitizer sink — 11 tests, driving each block through its real decorate() entry point. It asserts on a global execution canary rather than on rendered nodes, because a detached-but-owned element still fires handlers.

npx playwright test tests/blocks/xss.spec.js

Dependency Security

Renovate Configuration

Automated dependency management via .renovaterc.json (see the RHEA source repository). Key security impacts: devDependencies auto-merge for rapid patching, continuous schedule for zero-delay vulnerability response. See the DevOps Overview for how dependency and security checks fit into CI.

Supply Chain Controls

Control Implementation Description
Lock file package-lock.json Exact dependency versions pinned
npm ci CI pipeline Clean install from lock file only
Renovate Automated PRs Dependency updates with changelogs
Snyk scan GitHub Actions (Snyk-Scan job on pull requests) Third-party vulnerability scanning via the shared abbvie-migrated/SnykTemplates workflow
Limited runtime deps Architecture choice Both runtime libraries (mitt, DOMPurify) are vendored/bundled locally — no third-party CDN runtime dependency

External Script Policy

Script Source Loading Method Trust Mechanism
mitt (event emitter) Local bundle (scripts/vendor/mitt.min.js) ES module import Same-origin, nonce-trusted
DOMPurify Local bundle (scripts/dompurify.min.js) ES module import Same-origin, nonce-trusted
AEM RUM ot.aem.live Dynamic script tag CSP strict-dynamic
Block JS Same-origin Dynamic import() Same-origin, nonce-trusted
There are no third-party CDN runtime dependencies. Both mitt and DOMPurify are vendored/bundled locally and served same-origin. The only non-same-origin runtime script is Adobe's own RUM analytics (ot.aem.live).

Access Control

Repository Access

Level Scope Description
Admin abbvie-migrated org admins Full repository control
Write RHEA development team Push, merge, branch management
Read Consuming site teams Clone, pull, fork

AEM Author Access

Role Permissions Description
Content Author Create, edit, publish pages Day-to-day content management
Content Admin Fragment management, site config Global component management
Developer All above + code deployment Full authoring and development access

Security Best Practices

For Block Developers

Practice Description
Insert external HTML without a sink Use setSanitizedHTML() / sanitizeToFragment() for content from fragments, APIs, or editor events. Reach for DOMPurify only at a boundary where a string arrives — see HTML Sanitization
Never assign innerHTML, sanitized or not Sanitizing into a sink leaves the sink; a later edit can drop the sanitizer while the assignment survives
Avoid eval() and new Function() CSP will block these
Use loadScript() for dynamic scripts Maintains CSP trust chain via strict-dynamic
Validate user input Client-side validation for form fields (server-side is the ultimate authority)
Use getLinkAttributes() Automatically adds rel="noopener noreferrer" for external links
Avoid inline event handlers Use addEventListener() instead of onclick attributes

For Content Authors

Practice Description
Review ISI content Legal review before publishing safety information
Verify external links Ensure links point to trusted destinations
Use fragment system Load shared content via fragments, not inline HTML

Vulnerability Response

Step Action Owner
1 Detection — Renovate PR, npm audit, or manual report Automated / Any team member
2 Assessment — Evaluate severity and exploitability Security lead
3 Patch — Update dependency or apply code fix Developer
4 Verify — Confirm vulnerability is resolved Developer
5 Deploy — Merge fix to main Developer
On this page
h3
true