CKTIS / HTML
HTML concept: security
HTML security mechanisms constrain embedded capabilities and new-context relationships, but they do not sanitize untrusted content.
Version: WHATWG HTML Living Standard; index snapshot date recorded separately
Syntax
restrict embedded capability + isolate opener/referrer relationshipsA present empty sandbox on an iframe enables every restriction; allow-scripts lifts script blocking, while combining it with allow-same-origin can be unsafe for same-origin content.
srcdoc content is still an HTML document and must be constructed safely; sandbox does not repair markup injection or server flaws.
For target="_blank", rel="noopener" severs the opener, while rel="noreferrer" also omits referrer information and implies opener protection.
The example reads an empty sandbox, absence of allow-scripts, and rel="noopener" plus rel="noreferrer" tokens without opening a window.
Examples
<!doctype html>
<meta charset="utf-8">
<a id="external" href="https://example.test/" target="_blank" rel="noopener noreferrer">External</a>
<iframe id="preview" title="Preview" sandbox srcdoc="<p>Static preview</p>"></iframe>
<output id="result"></output>
<script>
const frame = document.querySelector("#preview");
const link = document.querySelector("#external");
frame.addEventListener("load", () => {
result.textContent = `sandboxPresent=${frame.hasAttribute("sandbox")}; tokens=${frame.sandbox.length}; scriptsAllowed=${frame.sandbox.contains("allow-scripts")}; noopener=${link.relList.contains("noopener")}; noreferrer=${link.relList.contains("noreferrer")}`;
}, { once: true });
</script>
Result
sandboxPresent=true; tokens=0; scriptsAllowed=false; noopener=true; noreferrer=true
The result verifies declared restrictions; it neither executes an attack nor proves complete application isolation.