Sample
bun 1.3.14: Pass non-zero-offset Uint8Array views safely to Bun hash, SHA-256, gzip, and file-write APIs without processing bytes outside the view
Verified sample for npm bun 1.3.14: Pass non-zero-offset Uint8Array views safely to Bun hash, SHA-256, gzip, and file-write APIs without processing bytes…
sha256:26d2c82aade11eeecc4816af2b310cb0609b299abb3878c451466acbc2b6db36
This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured.
How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people.
MIT-0
Execution evidence
The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.
- Evidence basis
- Signed contract pass
- Verification receipts
- 3
- Signing keys that built it
- 3
Declared environment
node linux x64 node node npm
Verification-run environments
| Environment | Contract | Stages | Run |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:d91480838ac982c9 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-17 |
| node 22 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-18 |
| node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5… |
2026-09-07 |
Case
HOW- Goal
- Pass non-zero-offset Uint8Array views safely to Bun hash, SHA-256, gzip, and file-write APIs without processing bytes outside the view
- Packages
- Symbols
-
- Bun.hash
- Bun.SHA256.update
- Bun.gzipSync
- Bun.gunzipSync
- Bun.write
- Environment
- node
- Created
- 2026-08-17T01:47:19Z
Contract
- Bun.hash produces the same result for a non-zero-offset Uint8Array view and an independent array containing only the view bytes, and a different result for the full backing array
- Bun.SHA256.update hashes only the supplied view range rather than the full backing ArrayBuffer
- Bun.gzipSync followed by Bun.gunzipSync preserves exactly the view bytes
- Bun.write persists exactly the view bytes and excludes the prefix and suffix in the backing array
Files
- csx.json
- package-lock.json
- package.json
- test/contract.mjs
Source
{"case":{"believed":"Bun binary APIs receive a typed array's entire backing ArrayBuffer, so passing a subarray with a non-zero offset hashes, compresses, or writes bytes outside the view.","caseId":"case:sha256:fff3aff566bbc5fa54d9b84a8c32f11f480d1ea84273d2085c9d57136fed77a8","contract":["Bun.hash produces the same result for a non-zero-offset Uint8Array view and an independent array containing only the view bytes, and a different result for the full backing array","Bun.SHA256.update hashes only the supplied view range rather than the full backing ArrayBuffer","Bun.gzipSync followed by Bun.gunzipSync preserves exactly the view bytes","Bun.write persists exactly the view bytes and excludes the prefix and suffix in the backing array"],"goal":"Pass non-zero-offset Uint8Array views safely to Bun hash, SHA-256, gzip, and file-write APIs without processing bytes outside the view","kind":"HOW","packages":["pkg:npm/bun@1.3.14"],"schemaVersion":1,"symbols":["Bun.hash","Bun.SHA256.update","Bun.gzipSync","Bun.gunzipSync","Bun.write"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","ecosystem":"npm","executionContext":"node","language":"node","os":"linux","packageManager":"npm","runtime":"node","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/bun@1.3.14"],"schemaVersion":1,"symbols":["Bun.hash","Bun.SHA256.update","Bun.gzipSync","Bun.gunzipSync","Bun.write"],"verifierAdapter":"node-typescript@1"}
{
"name": "bun-typedarray-contract",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "bun-typedarray-contract",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"bun": "1.3.14"
}
},
"node_modules/@oven/bun-darwin-aarch64": {
"version": "1.3.14",
"resolved": "https://registry.npmjs.org/@oven/bun-darwin-aarch64/-/bun-darwin-aarch64-1.3.14.tgz",
"integrity": "sha512-Omj20SuiHBOUjUBIyqtkNjSUIjOtEOJwmbix/ZyFH4BaQ6OZTaaRWIR4TjHVz0yadHgli6lLTiAh1uarnvD49A==",
"cpu": [
"arm64"
],
"license": "MIT",
"optional": true,
"os": [
"darwin"
]
},
"node_modules/@oven/bun-darwin-x64": {
"version": "1.3.14",
"resolved": "https://registry.npmjs.org/@oven/bun-darwin-x64/-/bun-darwin-x64-1.3.14.tgz",
"integrity": "sha512-FFj3QdU/OhlDyZOJ8CWfN5eWLpRlT4qjZg7lMQi7jA6GuoY5ajlO1zWLP/MuHYRSbXQUvV52RejNi8DVnAp13w==",
"cpu": [
"x64"
],
"license": "MIT",
"optional": true,
"os": [
"darwin"
]
},
"node_modules/@oven/bun-darwin-x64-baseline": {
"version": "1.3.14",
"resolved": "https://registry.npmjs.org/@oven/bun-darwin-x64-baseline/-/bun-darwin-x64-baseline-1.3.14.tgz",
"integrity": "sha512-OSfsTZstc898HHElhU4NccaBGOSSDn5VfahiVTnidZ9B/+wb7WTyfZJaBeJcfjwJ9H2W9uTh2TGtl3UfcXgV9g==",
"cpu": [
"x64"
],
"license": "MIT",
"optional": true,
"os": [
"darwin"
]
},
"node_modules/@oven/bun-freebsd-aarch64": {
"version": "1.3.14",
"resolved": "https://registry.npmjs.org/@oven/bun-freebsd-aarch64/-/bun-freebsd-aarch64-1.3.14.tgz",
"integrity": "sha512-LIKrXaFxAHybVO5Pf+9XP2FHUj/5APvXTUKk9dqHm5iFz4oH+W24cmhjkJirNujh9hKeTyrpWSe3no9JZKowIw==",
"cpu": [
"arm64"
],
"license": "MIT",
"optional": true,
"os": [
"freebsd"
]
},
"node_modules/@oven/bun-freebsd-x64": {
"version": "1.3.14",
"resolved": "https://registry.npmjs.org/@oven/bun-freebsd-x64/-/bun-freebsd-x64-1.3.14.tgz",
"integrity": "sha512-uwD+fGUH1ADpIF3B1U2jWzzb20QwRLZfj5QZ28GUCGrAJ/nTmWrD6YYGsblCY1wuhldRez3lU40AyuvSCyLYmw==",
"cpu": [
"x64"
],
"license": "MIT",
"optional": true,
"os": [
"freebsd"
]
},
"node_modules/@oven/bun-linux-aarch64": {
"version": "1.3.14",
"resolved": "https://registry.npmjs.org/@oven/bun-linux-aarch64/-/bun-linux-aarch64-1.3.14.tgz",
"integrity": "sha512-X5SsPZHs+iYO8R/efIcRtc7gT2Q2DgPfliCxEkx4cXBumwkw0c/EsHMNwH3EgGpCDaZ7IYVPhpCG/xBOQHEwZw==",
"cpu": [
"arm64"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
]
},
"node_modules/@oven/bun-linux-aarch64-android": {
"version": "1.3.14",
"resolved": "https://registry.npmjs.org/@oven/bun-linux-aarch64-android/-/bun-linux-aarch64-android-1.3.14.tgz",
"integrity": "sha512-y4kq5b85lsrmFb9Xvi4w9mA5IEFJkLMrSmYn06q24KjL9rUWDWO3VFZEtteZxUN5+ec3Zm5S8OnJw1umaCbVjA==",
"cpu": [
"arm64"
],
"license": "MIT",
"optional": true,
"os": [
"android"
]
},
"node_modules/@oven/bun-linux-aarch64-musl": {
"version": "1.3.14",
"resolved": "https://registry.npmjs.org/@oven/bun-linux-aarch64-musl/-/bun-linux-aarch64-musl-1.3.14.tgz",
"integrity": "sha512-jmqOA92Cd1NL/1XBd4bFkJLxQ86K0RW7ohxS2qzzAvuitO4JiIxjjTeCspoU44zCozH72HpfZfUE2On31OjnWA==",
"cpu": [
"arm64"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
]
},
"node_modules/@oven/bun-linux-x64": {
"version": "1.3.14",
"resolved": "https://registry.npmjs.org/@oven/bun-linux-x64/-/bun-linux-x64-1.3.14.tgz",
"integrity": "sha512-7OVTAKvwfPmSbIV1HpdOoVVx5VRc427GuPPne93N6vk4eQBPId9nXmZDh9/zGaKPdbVjVtQSZafWQoUjx38Utw==",
"cpu": [
"x64"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
]
},
"node_modules/@oven/bun-linux-x64-android": {
"version": "1.3.14",
"resolved": "https://registry.npmjs.org/@oven/bun-linux-x64-android/-/bun-linux-x64-android-1.3.14.tgz",
"integrity": "sha512-qe9e1d+3VAEU7nAA2ol9Jvmy/o99PVMSgZhHn7Q/9O3YcDrfEqyQ8zm4zoe5qTEo8HZH0dN03Le0Ys2eQPs7eg==",
"cpu": [
"x64"
],
"license": "MIT",
"optional": true,
"os": [
"android"
]
},
"node_modules/@oven/bun-linux-x64-baseline": {
"version": "1.3.14",
"resolved": "https://registry.npmjs.org/@oven/bun-linux-x64-baseline/-/bun-linux-x64-baseline-1.3.14.tgz",
"integrity": "sha512-q/8EdOC0yUE8FPeoOVq8/Pw5I9/tJaYmUfO/uDUAREx8IUnOJH1RJ5A3BjFqre8pvJoiZA9AovPJq5FnNNjSxA==",
"cpu": [
"x64"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
]
},
"node_modules/@oven/bun-linux-x64-musl": {
"version": "1.3.14",
"resolved": "https://registry.npmjs.org/@oven/bun-linux-x64-musl/-/bun-linux-x64-musl-1.3.14.tgz",
"integrity": "sha512-GBCB/k/sIqcr06eTNgg7g46qiUv35Jasx4XiccJ/n7RGqrE4RWUD/XJBbWFprVPjvqd59+QtSnS99XGqvftHfg==",
"cpu": [
"x64"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
]
},
"node_modules/@oven/bun-linux-x64-musl-baseline": {
"version": "1.3.14",
"resolved": "https://registry.npmjs.org/@oven/bun-linux-x64-musl-baseline/-/bun-linux-x64-musl-baseline-1.3.14.tgz",
"integrity": "sha512-n6iE71G4lQE4XkrZhQQcL5YUlxDbnq6nqV7zeQi33PMsLT/0kYE+RvHOtBWZ3w0wMdXZfINmp63hIb9ijUBGtw==",
"cpu": [
"x64"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
]
},
"node_modules/@oven/bun-windows-aarch64": {
"version": "1.3.14",
"resolved": "https://registry.npmjs.org/@oven/bun-windows-aarch64/-/bun-windows-aarch64-1.3.14.tgz",
"integrity": "sha512-T7s3x/BsVKQObGU6QDkZeI6wKynzqGbBH1yI77jrrj5siElclxr3DQrDIk8CV4G5/SJq2HHq4kpLyYY2DKCSmA==",
"cpu": [
"arm64"
],
"license": "MIT",
"optional": true,
"os": [
"win32"
]
},
"node_modules/@oven/bun-windows-x64": {
"version": "1.3.14",
"resolved": "https://registry.npmjs.org/@oven/bun-windows-x64/-/bun-windows-x64-1.3.14.tgz",
"integrity": "sha512-mUFWL3BoYkNpjd8e9PqROiFF/1Xeotq20mABJsiQH62jM1g5zqWh4khw1RZ6bX8Q8fWvlPaxG1PjofkmjUi3vg==",
"cpu": [
"x64"
],
"license": "MIT",
"optional": true,
"os": [
"win32"
]
},
"node_modules/@oven/bun-windows-x64-baseline": {
"version": "1.3.14",
"resolved": "https://registry.npmjs.org/@oven/bun-windows-x64-baseline/-/bun-windows-x64-baseline-1.3.14.tgz",
"integrity": "sha512-uIjLUC1S9DWgICzuoMba7vurBJnBruE4S5CxnvmZkdqWVXRzx1Rgu636HoH+k0qeaQCFh3jeG3JQ1y6fRHv0sw==",
"cpu": [
"x64"
],
"license": "MIT",
"optional": true,
"os": [
"win32"
]
},
"node_modules/bun": {
"version": "1.3.14",
"resolved": "https://registry.npmjs.org/bun/-/bun-1.3.14.tgz",
"integrity": "sha512-aB6GVd42x1Y5ie1K16SF+oLGtgSkwX9hgoDdIW88pjvfTccU8F1vfpoOt34QLv0dZ1v3XimtaxPlZUG81Gx9Zg==",
"cpu": [
"arm64",
"x64"
],
"hasInstallScript": true,
"license": "MIT",
"os": [
"darwin",
"linux",
"android",
"freebsd",
"win32"
],
"bin": {
"bun": "bin/bun.exe",
"bunx": "bin/bunx.exe"
},
"optionalDependencies": {
"@oven/bun-darwin-aarch64": "1.3.14",
"@oven/bun-darwin-x64": "1.3.14",
"@oven/bun-darwin-x64-baseline": "1.3.14",
"@oven/bun-freebsd-aarch64": "1.3.14",
"@oven/bun-freebsd-x64": "1.3.14",
"@oven/bun-linux-aarch64": "1.3.14",
"@oven/bun-linux-aarch64-android": "1.3.14",
"@oven/bun-linux-aarch64-musl": "1.3.14",
"@oven/bun-linux-x64": "1.3.14",
"@oven/bun-linux-x64-android": "1.3.14",
"@oven/bun-linux-x64-baseline": "1.3.14",
"@oven/bun-linux-x64-musl": "1.3.14",
"@oven/bun-linux-x64-musl-baseline": "1.3.14",
"@oven/bun-windows-aarch64": "1.3.14",
"@oven/bun-windows-x64": "1.3.14",
"@oven/bun-windows-x64-baseline": "1.3.14"
}
}
}
}
{
"name": "bun-typedarray-contract",
"version": "1.0.0",
"type": "module",
"license": "MIT-0",
"scripts": {
"test": "node test/contract.mjs"
},
"dependencies": {
"bun": "1.3.14"
}
}
import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';
import { createRequire } from 'node:module';
import { spawnSync } from 'node:child_process';
const require = createRequire(import.meta.url);
function isMuslLinux() {
if (process.platform !== 'linux') return false;
if (fs.existsSync('/etc/alpine-release')) return true;
try {
return !process.report?.getReport?.().header?.glibcVersionRuntime;
} catch {
return false;
}
}
function platformBinaryPackages(platform, architecture, musl) {
const packageArchitecture = architecture === 'arm64' ? 'aarch64' : architecture;
if (platform === 'linux' && musl) {
return packageArchitecture === 'x64'
? [
'@oven/bun-linux-x64-musl-baseline',
'@oven/bun-linux-x64-musl'
]
: [`@oven/bun-linux-${packageArchitecture}-musl`];
}
const packagePlatform = platform === 'win32' ? 'windows' : platform;
return [`@oven/bun-${packagePlatform}-${packageArchitecture}`];
}
function findBunBinary() {
const packagePath = require.resolve('bun/package.json');
const packageDirectory = path.dirname(packagePath);
const metadata = JSON.parse(fs.readFileSync(packagePath, 'utf8'));
const musl = isMuslLinux();
const executable = process.platform === 'win32' ? 'bun.exe' : 'bun';
const candidates = platformBinaryPackages(process.platform, process.arch, musl).map(
(packageName) => path.join(packageDirectory, '..', ...packageName.split('/'), 'bin', executable)
);
// The bun package's postinstall may copy a glibc binary into its own bin
// directory before trying a musl build. Never trust that fallback on Alpine.
if (!musl) {
candidates.push(
path.join(packageDirectory, 'bin', executable),
path.join(packageDirectory, 'bin', 'bun.exe'),
path.join(packageDirectory, metadata.bin?.bun ?? '')
);
}
const binary = candidates.find((candidate) => candidate && fs.existsSync(candidate));
assert.ok(binary, 'resolved bun package must contain a platform executable');
return binary;
}
assert.deepStrictEqual(platformBinaryPackages('linux', 'x64', true), [
'@oven/bun-linux-x64-musl-baseline',
'@oven/bun-linux-x64-musl'
]);
const bunBinary = findBunBinary();
const version = spawnSync(bunBinary, ['--version'], { encoding: 'utf8' });
assert.strictEqual(version.status, 0, version.stderr);
assert.strictEqual(version.stdout.trim(), '1.3.14');
const contract = String.raw`
import assert from 'node:assert/strict';
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
const backing = new Uint8Array([11, 22, 33, 44, 55, 66, 77, 88]);
const view = backing.subarray(2, 6);
const standalone = new Uint8Array([33, 44, 55, 66]);
assert.strictEqual(Bun.hash(view), Bun.hash(standalone));
assert.notStrictEqual(Bun.hash(view), Bun.hash(backing));
const viewDigest = new Bun.SHA256().update(view).digest('hex');
const standaloneDigest = new Bun.SHA256().update(standalone).digest('hex');
const backingDigest = new Bun.SHA256().update(backing).digest('hex');
assert.strictEqual(viewDigest, standaloneDigest);
assert.notStrictEqual(viewDigest, backingDigest);
const decompressed = Bun.gunzipSync(Bun.gzipSync(view));
assert.deepStrictEqual(Array.from(decompressed), Array.from(standalone));
const tempDirectory = fs.mkdtempSync(path.join(os.tmpdir(), 'csx-bun-subarray-'));
const output = path.join(tempDirectory, 'output.bin');
try {
await Bun.write(output, view);
const written = new Uint8Array(await Bun.file(output).arrayBuffer());
assert.deepStrictEqual(Array.from(written), Array.from(standalone));
} finally {
fs.rmSync(tempDirectory, { recursive: true, force: true });
}
console.log(JSON.stringify({ status: 'PASS' }));
`;
const run = spawnSync(bunBinary, ['-e', contract], { encoding: 'utf8' });
assert.strictEqual(run.status, 0, `Bun contract failed:\n${run.stdout}\n${run.stderr}`);
assert.deepStrictEqual(JSON.parse(run.stdout.trim()), { status: 'PASS' });