Separate storage, script visibility and delivery
Cookie observations answer different questions: was a value stored, can page JavaScript read it, and was it attached to a request? This experiment maps app.alpha.test, peer.alpha.test and other.beta.test to one local server. Different hosts remain different origins even with matching HTTPS scheme and port. The first two belong to the same alpha.test site in this setup, while the third is cross-site. Draw hosts, origins and sites before predicting delivery. No real user or production cookie is involved; values are fictional data created for the independent experiment. The goal is to connect each observed behavior to the attribute it tests instead of treating an attribute name as evidence that every relevant property has been established.
Prepare an independent Linux environment
The recorded run used Ubuntu 26.04, Node.js 24, Playwright 1.64.1 and Chromium 156.0.8078.4. Prepare OpenSSL and the NSS certutil tool on Linux, install the pinned Playwright package in a working directory, then install its Chromium and required system dependencies. Save the published program as web-boundary-lab.cjs and run node web-boundary-lab.cjs cookies. The browser maps the three teaching hosts to loopback rather than contacting public sites. The program creates a temporary CA and server certificate, importing the CA only into a certificate database under a dedicated temporary HOME. It does not modify an everyday browser profile. TLS certificate validation remains enabled. If the environment changes, record the new browser and dependency versions rather than assuming the earlier observations are a measurement of the new setup.
Hold unrelated delivery conditions constant
The set endpoint issues Strict, Lax and None cookies with Secure and HttpOnly, varying their SameSite attribute while holding the other main conditions constant. Additional cookies provide a script-visible value and a Path-restricted value under /private. All are host-only because Domain is omitted. A page on peer does not make app’s host-only cookies belong to peer. That is distinct from a page on peer causing a request to app. The echo endpoint returns the Cookie header actually received, avoiding an inference based only on browser storage. It also permits credentialed CORS observations from the specified teaching origins so that the test can read those echo results. That observation facility is not presented as a production authorization or CSRF defense.
Interpret HttpOnly and same-site observations
The initial document.cookie observation returns only visible=demo. The main three cookies are HttpOnly, so ordinary script cannot read their values despite their presence in browser storage. Next a page on peer.alpha.test performs a credentialed fetch to app.alpha.test. Strict and Lax were delivered in the recorded environment: the origins differ, but the sites match in this setup. This contradicts a blanket claim that a different origin means no cookie attachment. It also separates inability to read a cookie value from inability to cause a request carrying that cookie. Those observations test different responsibilities. For each reported case, identify the initiating page, destination host and request method on the diagram before attributing the result to an attribute.
Compare cross-site fetch with top-level navigation
From other.beta.test, a credentialed fetch to app delivered only None in the recorded environment; Strict and Lax were absent. Clicking an actual link on the other page to navigate the top-level frame to app using GET also delivered Lax. The test deliberately triggers a link rather than substituting a direct navigation without the same initiating context. SameSite=None permits cross-site delivery under that attribute’s rule, but third-party-cookie restrictions or other browser policy can still block actual transmission. The code does not assert that None is present in every environment. It checks the stated Strict and Lax distinctions and records observed None behavior. Keeping policy eligibility separate from measurement makes different results on another browser something to investigate rather than something to conceal.
Check Path and host-only controls
The scoped cookie appears on app’s /private/echo and not on its ordinary /echo. App’s host-only Lax cookie is also absent on peer’s echo endpoint. These are delivery-scope observations, not access control for every resource under /private. The server still needs to decide which actor may receive a protected response. Running the program prints JSON observations, browser and Node versions and the enabled TLS-validation condition. Missing dependencies must produce a failed preparation, not a silently skipped passing test. A finally block closes browser and server and removes the temporary HOME and certificates. It does not clear ordinary user cookies. The independent setup and teardown are part of the reproducible experiment.
const fs = require('node:fs');
const os = require('node:os');
const path = require('node:path');
const https = require('node:https');
const {execFileSync} = require('node:child_process');
const {randomBytes} = require('node:crypto');
const assert = require('node:assert/strict');
const {chromium} = require('playwright');
const mode = process.argv[2] || 'cookies';
const work = fs.mkdtempSync(path.join(os.tmpdir(), 'web-boundary-'));
const home = path.join(work, 'home');
const db = path.join(home, '.pki', 'nssdb');
fs.mkdirSync(db, {recursive:true});
function run(command, args) { execFileSync(command, args, {cwd:work, stdio:'pipe'}); }
run('openssl', ['req','-x509','-newkey','rsa:2048','-nodes','-days','1','-subj','/CN=Teaching Root','-addext','basicConstraints=critical,CA:TRUE','-addext','keyUsage=critical,keyCertSign,cRLSign','-keyout','ca.key','-out','ca.pem']);
run('openssl', ['req','-newkey','rsa:2048','-nodes','-subj','/CN=app.alpha.test','-keyout','server.key','-out','server.csr']);
fs.writeFileSync(path.join(work,'server.ext'), 'subjectAltName=DNS:app.alpha.test,DNS:peer.alpha.test,DNS:other.beta.test\nbasicConstraints=critical,CA:FALSE\nkeyUsage=critical,digitalSignature,keyEncipherment\nextendedKeyUsage=serverAuth\n');
run('openssl', ['x509','-req','-in','server.csr','-CA','ca.pem','-CAkey','ca.key','-CAcreateserial','-days','1','-extfile','server.ext','-out','server.pem']);
run('certutil',['-N','-d','sql:'+db,'--empty-password']);
run('certutil',['-A','-d','sql:'+db,'-n','Teaching Root','-t','C,,','-i',path.join(work,'ca.pem')]);
let app, peer, other, unsafeChanges = 0, safeChanges = 0;
const token = randomBytes(24).toString('hex');
const server = https.createServer({key:fs.readFileSync(path.join(work,'server.key')),cert:fs.readFileSync(path.join(work,'server.pem'))}, (req,res)=>{
const route = req.url.split('?')[0];
const cookie = req.headers.cookie || '';
const origin = req.headers.origin || '';
const send = (status,data)=>{res.writeHead(status,{'Content-Type':'application/json'});res.end(JSON.stringify(data));};
if(route==='/set') {
res.setHeader('Set-Cookie',[
'Strict=1; Path=/; Secure; HttpOnly; SameSite=Strict',
'Lax=1; Path=/; Secure; HttpOnly; SameSite=Lax',
'None=1; Path=/; Secure; HttpOnly; SameSite=None',
'visible=demo; Path=/; Secure; SameSite=Lax',
'scoped=1; Path=/private; Secure; SameSite=None'
]);
return send(200,{set:true});
}
if(route==='/echo'||route==='/private/echo') {
if([app,peer,other].includes(origin)) {
res.setHeader('Access-Control-Allow-Origin',origin);
res.setHeader('Access-Control-Allow-Credentials','true');
}
return send(200,{cookie,origin,method:req.method});
}
if(route==='/token') return send(200,{token});
if(route==='/unsafe'||route==='/safe') {
let data='';req.on('data',part=>data+=part);req.on('end',()=>{
if(!cookie.split('; ').includes('Lax=1')) return send(401,{error:'no test session'});
const supplied = new URLSearchParams(data).get('csrf');
if(route==='/safe'&&(origin!==app||supplied!==token)) return send(403,{error:'request rejected'});
if(route==='/safe') safeChanges++; else unsafeChanges++;
return send(200,{changed:true});
});return;
}
res.writeHead(200,{'Content-Type':'text/html'});
res.end(`<a id="nav" href="${app}/echo">Navigate to app</a><form method="post" action="${app}/unsafe"><label>Token<input name="csrf"></label><button>Send</button></form>`);
});
(async()=>{
let browser;
try {
await new Promise(resolve=>server.listen(0,'127.0.0.1',resolve));
const port=server.address().port;
app=`https://app.alpha.test:${port}`;peer=`https://peer.alpha.test:${port}`;other=`https://other.beta.test:${port}`;
browser=await chromium.launch({headless:true,env:{...process.env,HOME:home},args:['--no-proxy-server','--host-resolver-rules=MAP *.alpha.test 127.0.0.1,MAP *.beta.test 127.0.0.1']});
const context=await browser.newContext({ignoreHTTPSErrors:false});
const page=await context.newPage();
await page.goto(app+'/set');
const report={mode,browser:browser.version(),playwright:require('playwright/package.json').version,node:process.version,os:os.release(),tlsValidation:true,results:[]};
if(mode==='cookies') {
const visible=await page.evaluate(()=>document.cookie);
assert(visible.includes('visible=demo')&&!visible.includes('Strict=')&&!visible.includes('Lax=')&&!visible.includes('None='));
report.results.push({case:'document.cookie',observed:visible});
await page.goto(peer+'/page');
const same=await page.evaluate(async url=>(await fetch(url,{credentials:'include'})).json(),app+'/echo');
assert(same.cookie.includes('Strict=1')&&same.cookie.includes('Lax=1'));
report.results.push({case:'same-site cross-origin fetch',...same});
await page.goto(other+'/page');
const cross=await page.evaluate(async url=>(await fetch(url,{credentials:'include'})).json(),app+'/echo');
assert(!cross.cookie.includes('Strict=1')&&!cross.cookie.includes('Lax=1'));
report.results.push({case:'cross-site fetch; None subject to browser policy',...cross});
const navigation=page.waitForResponse(r=>r.url()===app+'/echo'&&r.request().isNavigationRequest());
await page.locator('#nav').click();
const top=await (await navigation).json();
assert(top.cookie.includes('Lax=1')&&!top.cookie.includes('Strict=1'));
report.results.push({case:'cross-site top-level GET',...top});
const privateResponse=await page.goto(app+'/private/echo');
assert((await privateResponse.json()).cookie.includes('scoped=1'));
const ordinary=await page.goto(app+'/echo');
assert(!(await ordinary.json()).cookie.includes('scoped=1'));
const hostOnly=await page.goto(peer+'/echo');
assert(!(await hostOnly.json()).cookie.includes('Lax=1'));
report.results.push({case:'Path and host-only controls',pass:true});
} else if(mode==='csrf') {
async function submit(source,target,supplied='') {
await page.goto(source+'/page');
await page.locator('form').evaluate((form,url)=>form.action=url,app+target);
await page.getByRole('textbox',{name:'Token'}).fill(supplied);
const response=page.waitForResponse(r=>r.url()===app+target&&r.request().isNavigationRequest());
await page.getByRole('button',{name:'Send',exact:true}).click();
return (await response).status();
}
assert.equal(await submit(peer,'/unsafe'),200);
assert.equal(unsafeChanges,1);
assert.equal(await submit(peer,'/safe'),403);
assert.equal(await submit(app,'/safe','wrong'),403);
assert.equal(await submit(peer,'/safe',token),403);
assert.equal(await submit(app,'/safe',token),200);
assert.equal(safeChanges,1);
report.results.push({case:'same-site cross-origin unsafe POST',status:200,changes:unsafeChanges},{case:'safe: missing token, wrong token, wrong origin',status:403},{case:'safe: correct origin and token',status:200,changes:safeChanges});
} else throw Error('Expected cookies or csrf');
console.log(JSON.stringify(report));
} finally {
if(browser) await browser.close();
await new Promise(resolve=>server.close(resolve));
fs.rmSync(work,{recursive:true,force:true});
}
})().catch(error=>{console.error(error);process.exitCode=1;});Exercise: use separate delivery and permission columns
For a page on peer requesting a state change at app, write separate columns for possible cookie delivery and permission to perform the operation. Under this same-site setup, Lax or Strict cookies can accompany a request, but that does not prove intent or resource-specific update authority. The worked design lists actor resolution, CSRF checks and authorization separately. Next evaluate the claim that setting Path to /private automatically restricts who may read documents there. It confuses cookie delivery with access control. Finally, if another browser omits None, inspect its third-party-cookie policy and the initiating and destination sites before declaring an attribute implementation bug. Use the CSRF experiment to explore why automatic attachment and intended action need distinct verification.