The v0.7.3 release includes a major security overhaul to ensure NHTML is ready for production environments.
- DOMPurify Integration: The
bridge.jsnow strictly sanitizes all HTML content before injecting it into the DOM. - Opcode Level Sanitization: This affects
REPLACE_INNER,APPEND_HTML,INSERT_BEFORE, andINSERT_AFTER. - Fallback Policy: If DOMPurify is missing, an aggressive manual sanitizer is used (stripping scripts, iframes, objects, and dangerous attributes like
on*orjavascript:).
- Cross-Origin WebSocket Hijacking: The Gateway now performs strict Origin verification.
- Allowed Origins: You must configure
allowed_originsinnhtml.config.tomlto restrict which domains can connect to the WebSocket gateway. - Default Policy: In development mode,
localhostand127.0.0.1are allowed. In production, an empty or missing Origin header will result in a 403 Forbidden error ifallowed_originsis set.
- Resolved Path Enforcement: Both the Rust Gateway and the PHP Router use
canonicalize()andrealpath()to resolve paths. - Root Jail: All file inclusions and static file serves are strictly checked to ensure they stay within the configured project root.
- HMAC-SHA256 Signatures: Every EVENT packet from the client is signed with a session-specific secret.
- Sequence IDs: Prevents replay attacks by ensuring each event has a strictly increasing sequence number.
- Resolution Order:
$NHTML_CONFIG(env) >./nhtml.config.toml>{exe_dir}/nhtml.config.toml. - Validation: The binary will immediately exit with a fatal error if the configuration file is malformed, preventing accidental insecure defaults.
La version v0.7.3 inclut une refonte majeure de la sécurité pour garantir que NHTML est prêt pour la production.
- Intégration DOMPurify : Le
bridge.jssanitise désormais strictement tout le contenu HTML avant injection. - Sanitisation au niveau Opcode : S'applique à
REPLACE_INNER,APPEND_HTML,INSERT_BEFORE, etINSERT_AFTER. - Fallback Agressif : Si DOMPurify est absent, un sanitiseur manuel dépouille le contenu de toute balise dangereuse (scripts, iframes, etc.) et attributs
on*.
- Cross-Origin WebSocket Hijacking : La Gateway effectue une vérification stricte de l'en-tête
Origin. - Whitelist d'Origines : Configurez
allowed_originsdansnhtml.config.tomlpour restreindre les domaines autorisés. - Politique par défaut : En mode dev,
localhostest autorisé. En production, un Origin manquant ou non listé entraîne une erreur 403.
- Résolution Stricte : La Gateway et le routeur PHP utilisent
canonicalize()etrealpath(). - Projet "Jail" : Toute inclusion est vérifiée pour s'assurer qu'elle reste dans le répertoire racine du projet.
- Signatures HMAC-SHA256 : Chaque paquet EVENT est signé avec un secret unique par session.
- Sequence IDs : Empêche les attaques par rejeu via une numérotation stricte des événements.
- Ordre de Résolution :
$NHTML_CONFIG(env) >./nhtml.config.toml>{exe_dir}/nhtml.config.toml. - Validation Fatale : Le binaire s'arrête immédiatement si le fichier de config est invalide, évitant tout mode dégradé non sécurisé.
Update (v0.7.3): This vulnerability has been officially resolved in the latest dependency tree update. NHTML Gateway v0.7.3 and newer are no longer affected.
© 2026 NemStudio18 — Security First.