Security Model
XXE rejection, realpath containment, strict slug allowlists, CSRF guards, gated debug output, and PHC sandbox enforcement.
Xao is designed to fail closed at every trust boundary, pairing framework-level guards in PHP with PHC's Rust sandbox.
Defense-in-Depth Controls
XXE & DOCTYPE rejection: Both
DomDoc::parseXmlToDomDocument()andPhcNativeXsltDriver::transform()reject<!DOCTYPEand<!ENTITYdeclarations upfront (XmlParseException/XsltTransformException), and PHC disables external DTD and entity loading natively.Strict
realpath()containment:DomDoc::resolveSafeFilePath($filePath, $baseDir)verifies canonical paths remain strictly under$baseDir.Transformer::resolveStylesheet()andPhcNativeXsltDriver::resolveStylesheet()reject NUL bytes, backslashes,..traversal segments, absolute paths, and symlink escapes outside$stylesheetRoot(HTTP403).PHC independently sandboxes
xsl:include,xsl:import, anddocument()URIs againstsandbox.allowed_roots.
Slug allowlists (
Xao\App\SlugValidator): Slugs must match^[a-z0-9]+(?:-[a-z0-9]+)*$(max 64 chars). Traversal sequences (..,/,\,\0) fail closed with HTTP403, and malformed characters fail with HTTP400.Gated debug output: Legacy 2003 Xao allowed
?xao:XMLand?xao:Textunconditionally from query parameters. ModernAppDocblocks debug XML/text output with HTTP403unless$debug === trueis explicitly configured (XAO_DEBUG=1).Safe Markdown defaults:
phc_markdown_to_dom()andphc_markdown_to_xml()run withunsafe_html = falseby default, stripping raw HTML blocks and inline<script>tags before XSLT transformation.CSRF protection & sessions (
ReferenceApp): State-mutating POST routes validate per-session tokens viaXao\App\CsrfGuard::verify()usinghash_equals()and fail closed with HTTP403.Error suppression in HTTP responses:
phc.tomlsetsdisplay_errors = "0"so host paths and stack traces never leak to clients.