Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions docs/RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# Release notes

## 0.1.1 — security scan triage

No public API, runtime dependency, or behavior change: `@pegma/mail@0.1.1` is
byte-equivalent in surface to `0.1.0` and still requires exactly
`@pegma/spine@0.1.1` and `@pegma/storage-core@0.4.0`.

This release records the 2026-07-29 triage of `docs/securityscan.md`:

- the `uuid` buffer-bounds advisory (GHSA-w5hq-g745-h8pq) is cleared from the
development tree by a root `overrides` pin to `^11.1.1`, with a lockfile
regression test; and
- the hardcoded-emulator-key and unvalidated-recipient findings were
re-examined and disputed as not valid, so no source changed for either.

`npm audit --omit=dev` remains 0. The residual `brace-expansion` and
`@opentelemetry/core` advisories are development-only, are documented as
accepted in `docs/securityscan.md` with the verified reason each patched
release is API-incompatible with azurite's pinned tree, and never reach a
published artifact.

## 0.1.0 — first advertised supported release

Status: prepared for reviewed merge, a protected signed annotated `v0.1.0`
Expand Down
93 changes: 78 additions & 15 deletions docs/securityscan.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ evidence, exploitability assessment, and file references.
for hash/commit comparisons, signed-tag + origin/main-ancestry + clean-tree
enforcement before publish, OIDC-only publish gate. No findings yet.
- **[OK] `.github/workflows/*.yml`** — reviewed. All actions pinned by full
commit SHA, least-privilege `permissions` (`contents: read`; `id-token:
write` only in the publish job), no `pull_request_target`, no script
injection from event context (release tag used only as a `ref` string and in
artifact names, not interpolated into shell), protected-environment gate
(`environment: npm-publish`). No findings yet.
commit SHA, least-privilege `permissions`
(`contents: read`, with `id-token: write` only in the publish job), no
`pull_request_target`, no script injection from event context (release tag
used only as a `ref` string and in artifact names, not interpolated into
shell), protected-environment gate (`environment: npm-publish`). No findings
yet.
- **[OK] `test/azurite.ts`** — reviewed. Local emulator harness; binds to
127.0.0.1, spawns node with fixed args, no secrets. No findings.

Expand Down Expand Up @@ -62,6 +63,38 @@ evidence, exploitability assessment, and file references.
would downgrade azurite (breaking) and is not advisable. Consider
`overrides` for `brace-expansion`/`uuid` if a compatible bump exists, or
accept with documented justification since exposure is test-only.
- ✅ Resolved 2026-07-29 — pinned `uuid` to `^11.1.1` through a root
`overrides` entry, clearing GHSA-w5hq-g745-h8pq (all three `uuid` advisory
ranges) from the dev tree; the remaining two advisories are accepted with
the verified justification below, because each one's only patched release is
API-incompatible with the tree azurite pins.
- **Override feasibility, verified 2026-07-29:**
- `uuid` — **overridden.** `8.3.2` → `11.1.1`. Both dependents consume named
exports (`require("uuid").v4` in `sequelize`, `v4` in `@azure/ms-rest-js`),
which `uuid@11` still provides; `sequelize`, `@azure/ms-rest-js`, and the
Azurite conformance suite were all exercised against it.
- `brace-expansion` — **not overridable.** `5.0.8` is the sole patched
release, and its CommonJS entry exports
`{ EXPANSION_MAX, EXPANSION_MAX_LENGTH, expand }` rather than a callable
module. `minimatch@3.1.5` does `expand(pattern)` on the bare require, so
the override makes every glob throw
`TypeError: expand is not a function`, breaking `glob@7` → `rimraf@3`.
Reaching a compatible `minimatch` would require overriding `glob` and
`rimraf` too — effectively the azurite downgrade this finding already
rejects.
- `@opentelemetry/core` — **not overridable.** `2.8.0`+ is the sole patched
line, but `applicationinsights@2.9.8` pins `@opentelemetry/sdk-trace-base@1.30.1`,
which reads `TracesSamplerValues.AlwaysOn` — removed in core 2.x. Forcing
core `2.10.0` makes tracer construction throw
`TypeError: Cannot read properties of undefined (reading 'AlwaysOn')`.
Note this failure is latent: `applicationinsights` still loads and
`setup().start()` still succeeds, so the test suite does **not** catch it.
- **Residual risk accepted:** 5 high (`brace-expansion` chain) and 4 moderate
(`@opentelemetry/core` chain) advisories remain, dev-only.
`npm audit --omit=dev` remains **0**, so the release packer's audit gate is
unaffected and the published `@pegma/mail` tarball is unchanged. Both
chains are reachable only from azurite's own fixed-string internals on
127.0.0.1; revisit when azurite bumps `rimraf` and `applicationinsights`.

### FINDING 2 — Hardcoded storage account key in test file

Expand All @@ -77,6 +110,16 @@ evidence, exploitability assessment, and file references.
package (`tsconfig` excludes `src/**/*.test.ts`; `files` ships only `dist/**`).
Flagged so secret scanners don't surprise future reviewers; no action needed
beyond awareness.
- ⚠️ Disputed 2026-07-29 — not a valid finding: the string is Microsoft's
published Azurite/Azure Storage Emulator well-known development key, not a
credential. It is documented verbatim in Microsoft's public docs, is
identical in every Azurite installation, and the connection string it sits
in targets `http://127.0.0.1:${TABLE_PORT}` only
(`packages/mail/src/azurite.test.ts:18-26`), so it authenticates to nothing
but a local emulator and grants zero access to any real Azure resource.
Rotation is meaningless (Azurite would reject any other key) and removal
would only obscure it behind indirection. Retained deliberately; there is no
secret to remove and no code change is warranted.

- **[OK] `packages/mail/src/azurite.test.ts`** — reviewed (see Finding 2 for
the emulator key note). `allowInsecureConnection: true` and `http://` are
Expand All @@ -88,7 +131,7 @@ evidence, exploitability assessment, and file references.
- **[OK] `packages/mail/src/test-support.ts`** — test-only projection
helpers; `JSON.parse` on test-owned payloads only; excluded from build.
- **[OK] `tests/release-packages.test.ts`** (1,218 lines) — notably contains
*positive* security regression tests: verifies npm tokens
_positive_ security regression tests: verifies npm tokens
(`NODE_AUTH_TOKEN`/`NPM_TOKEN`/`NPM_AUTH_TOKEN`) and hostile
`npm_config_*` registry overrides do **not** leak into spawned release
processes, and that a hostile registry cannot redirect publish traffic.
Expand Down Expand Up @@ -123,6 +166,20 @@ evidence, exploitability assessment, and file references.
recipient/content authorization to the host. If defense-in-depth is
desired, a single-address format check could be added here, at the cost of
constraining legitimate provider-specific address forms.
- ⚠️ Disputed 2026-07-29 — not a valid finding: `normalizePreparedMail` is
reached only from `await options.preparation.prepare(...)`
(`packages/mail/src/index.ts:1622-1630`), i.e. the host-owned preparation
port. That is the trusted side of the boundary `SECURITY.md:7-10` defines,
so there is no untrusted input path to the value at all — the premise of the
finding is a trust-boundary misread, not a missing check. The injection this
would notionally prevent is already blocked upstream: `CONTROL` rejects
CR/LF in `recipient`, and header names/values are separately constrained
(`/^[A-Za-z0-9-]{1,64}$/`, ≤64 headers, ≤8 KiB, no controls), so no
SMTP-header injection is reachable. Adding an email-format check would also
be actively wrong here: this package is provider-neutral by mandate
(`AGENTS.md`, "no deliverability abstraction"), and hard-coding one address
grammar would reject legitimate provider-specific forms that hosts are
entitled to pass. Deliberately left as-is.

### Deep-logic review notes (no findings)

Expand All @@ -143,8 +200,8 @@ The following areas were specifically examined and found sound:
Nothing auto-replays or disappears. (`index.ts:1039-1049, 1471-1477`)
- **Prototype-pollution / getter resistance:** all untrusted object reads go
through own-data-property snapshots; header map keys are charset-restricted
(so `__proto__` is unreachable); frozen outputs. (`index.ts:482-542,
984-1017`)
(so `__proto__` is unreachable); frozen outputs.
(`index.ts:482-542, 984-1017`)
- **Regex safety:** all patterns are bounded/linear (no nested quantifiers);
no ReDoS candidates.
- **Integer/overflow safety:** exponential backoff exponent capped at 19 and
Expand All @@ -163,21 +220,27 @@ The following areas were specifically examined and found sound:

## Summary

| # | Finding | Severity | Exploitability |
|---|---------|----------|----------------|
| 1 | Vulnerable transitive dev dependencies via `azurite` (brace-expansion DoS, uuid bounds, OpenTelemetry baggage) | **Low** (dev-only; 0 runtime vulns) | No path through published package; CI/local test emulator only |
| 2 | Hardcoded Azurite development storage key in test | **Informational** | None — Microsoft's public well-known emulator key, local-only |
| 3 | Recipient not format-validated as an email address | **Informational** | Requires compromised host preparation port; injection already blocked |
| # | Finding | Severity | Exploitability | Disposition |
| --- | -------------------------------------------------------------------------------------------------------------- | ----------------------------------- | --------------------------------------------------------------------- | ----------------------------------------------------------------- |
| 1 | Vulnerable transitive dev dependencies via `azurite` (brace-expansion DoS, uuid bounds, OpenTelemetry baggage) | **Low** (dev-only; 0 runtime vulns) | No path through published package; CI/local test emulator only | ✅ Resolved 2026-07-29 (`uuid` pinned; other two chains accepted) |
| 2 | Hardcoded Azurite development storage key in test | **Informational** | None — Microsoft's public well-known emulator key, local-only | ⚠️ Disputed 2026-07-29 |
| 3 | Recipient not format-validated as an email address | **Informational** | Requires compromised host preparation port; injection already blocked | ⚠️ Disputed 2026-07-29 |

**Overall assessment:** The repository is in strong security shape. The
published package (`@pegma/mail`) has zero known-vulnerable runtime
dependencies, a minimal ship list (`dist/**` only), defense-in-depth input
validation, fail-closed state transitions, and a heavily hardened,
OIDC-only, signed-tag release pipeline with least-privilege, SHA-pinned CI.
The only actionable item is Finding 1 (track upstream `azurite` fixes);
Findings 2 and 3 require no action.
The only actionable item was Finding 1, now partially remediated by the
`uuid` override; Findings 2 and 3 were re-examined and disputed as
not-valid, and no code changed for either.

_Scan completed: 2026-07-28. Files reviewed: all tracked source, tests,
scripts, workflows, configs, and docs (excluding `node_modules/` and
generated `dist/`)._

_Findings triaged and remediated: 2026-07-29. Every finding above was
independently re-verified against the code and the live dependency tree
before its disposition was recorded; `npm audit` went from 12 advisories
(5 high, 7 moderate) to 9 (5 high, 4 moderate), with
`npm audit --omit=dev` at 0 throughout._
15 changes: 9 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,8 @@
"prettier": "^3.9.6",
"typescript": "^7.0.2",
"vitest": "^4.1.10"
},
"overrides": {
"uuid": "^11.1.1"
}
}
2 changes: 1 addition & 1 deletion packages/mail/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pegma/mail",
"version": "0.1.0",
"version": "0.1.1",
"description": "Durable transactional mail jobs that commit in the caller's own transaction.",
"license": "MIT",
"type": "module",
Expand Down
25 changes: 25 additions & 0 deletions tests/release-packages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,31 @@ describe("release package metadata", () => {
});
});

it("keeps every resolved uuid past the buffer-bounds advisory", () => {
const rootManifest = JSON.parse(
readFileSync(join(process.cwd(), "package.json"), "utf8"),
) as { overrides: Record<string, string> };
expect(rootManifest.overrides).toMatchObject({ uuid: "^11.1.1" });

const lockfile = JSON.parse(
readFileSync(join(process.cwd(), "package-lock.json"), "utf8"),
) as { packages: Record<string, { version?: string }> };
const resolved = Object.entries(lockfile.packages).filter(([path]) =>
/(?:^|\/)node_modules\/uuid$/.test(path),
);
expect(resolved.length).toBeGreaterThan(0);
const vulnerable = resolved.filter(([, entry]) => {
const [major = 0, minor = 0, patch = 0] = (entry.version ?? "0")
.split(".")
.map(Number);
if (major !== 11) return major < 11;
return minor < 1 || (minor === 1 && patch < 1);
});
expect(
vulnerable.map(([path, entry]) => `${path}@${entry.version}`),
).toEqual([]);
});

it("validates package metadata, exact dependencies, and lockfile together", async () => {
const releaseTag = process.env.RELEASE_TAG;
const releaseCommit = process.env.RELEASE_COMMIT;
Expand Down
Loading