Skip to content

test(workers): pin the 64 KiB AAD boundary through the wasm binding (LAB-9108) - #234

Merged
27Bslash6 merged 1 commit into
mainfrom
agent/miss-huang/LAB-9108-wasm-aad-boundary
Oct 12, 2026
Merged

27Bslash6 merged 1 commit into
mainfrom
agent/miss-huang/LAB-9108-wasm-aad-boundary

Conversation

@27Bslash6

Copy link
Copy Markdown
Contributor

The Workers test lane now drives a secure-cache key to the AES-GCM AAD limit through the real wasm binding: a key whose AAD is exactly 65 536 bytes round-trips, and a key one byte longer throws ConfigurationError from both set() and get() before any backend call.

Why

The secure-key AAD pre-flight (EncryptionManagerCore.validateKey) is tested at its boundary only in cache.test.ts, which encrypts through the NAPI binding. The Workers entrypoint encrypts through cachekit-core-wasm, whose MAX_AAD_SIZE the TS constant claims to mirror, and nothing drove a key to the limit there. If the two limits drifted, an at-limit key would pass the TS check and fail inside encrypt() inside the reliability executor, on Workers only, with every test green.

Change

Test code only, in test/workers/cache.workers.test.ts. One it.each over compression: true / false. The key budget is written out from the v0x03 AAD layout (1 + 16 + tenant id + keyPrefix + key + msgpack + True/False), using the cache's own tenant id and a backend keyPrefix, since the AAD binds keyPrefix + key. L1 is off so the read decrypts through wasm. The over-limit case counts backend get/set calls and expects zero.

Verification

  • pnpm --filter @cachekit-io/cachekit test:workers: 171 passed (after build:wasm and the package build).
  • Mutation: with the TS MAX_AAD_SIZE raised by one, both new cases fail (promise resolved "undefined" instead of rejecting). The wasm encrypt() refuses the 65 537-byte AAD inside the executor and degradation swallows it, which is the failure this test exists to catch.
  • tsc -p tsconfig.test.json, eslint and prettier clean on the file.

No docs change: test-only.

Closes LAB-9108

The secure-key AAD boundary tests ran only through the NAPI binding. Drive a
secure-cache key to exactly 65 536 AAD bytes through the Workers lane, so a
drift between the TS MAX_AAD_SIZE and the wasm one fails a test instead of
failing inside encrypt() on Workers only. The key budget counts the tenant id,
the backend keyPrefix and the compression flag, for both flag values.
@kodus-27b

kodus-27b Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the `@kody start-review` command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Providing Context (Files & MCPs)

Add these hints in your PR description (or a comment) to unlock deeper checks:

  • Ticket / Acceptance Criteria: `Refs: ABC-123` (Linear/Jira/Asana/ClickUp/Trello) or a direct ticket link.
  • Bugfix Validation: a Sentry/Datadog/Bugsnag event link (or paste the stack trace/error message).
  • Endpoint Risk: mention the route (e.g., `POST /api/payments`) or controller/action name.
  • Attach a repo file as context: use an explicit marker like `@file:docs/guide.mdx#L10-L50` (replace with your real path).
  • API Contract Docs: include `@file:openapi.yaml` or `@file:swagger.json` when changing routes/schemas.
  • Definition of Done / Standards: include `@file:DOD.md` or `@file:CONTRIBUTING.md` if your repo has them.
  • Design System Source of Truth: include `@file:ui/index.ts` (replace with your DS entrypoint path).
  • Feature Flags: include the flag key/name and `@file:flags.ts` / `@file:config.json` (and optionally the PostHog flag name).
  • Edge/CDN Rules: link the Cloudflare rule/zone or describe the intended redirect/header behavior.
  • Attach an MCP tool output: use `@mcp<provider|tool>` (replace with an installed MCP provider + tool, e.g., `@mcp<sentry|events.search>`).
Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ✅

Access your configuration settings here.

@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: cachekit-io/cachekit-ts/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 0bcb735d-2745-426c-b73b-76daeef3f34b

📥 Commits

Reviewing files that changed from the base of the PR and between d0eaf3e and 7daa64d.


📒 Files selected for processing (1)
  • packages/cachekit/test/workers/cache.workers.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.



Summary by CodeRabbit

  • Tests
    • Added coverage for encrypted cache keys at the 65,536-byte boundary, with compression enabled and disabled. Keys at the limit round-trip successfully; longer keys are rejected on set and get.

Walkthrough

The workerd tests cover encrypted cache keys at the 65,536-byte AAD limit. They check exact-limit round trips and verify that keys one character over the limit are rejected by set and get before either backend method is called.

Changes

Encrypted cache key boundary

Layer / File(s) Summary
AAD boundary test cases
packages/cachekit/test/workers/cache.workers.test.ts
The tests calculate the key-length budget and check compressed and uncompressed encrypted keys. Exact-limit keys round-trip; keys one character over the limit cause ConfigurationError on set and get without backend calls.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

Merge Risk: ⚪ Minimal · up to 7daa6

This change only adds tests for the encrypted cache key size limit. It does not alter production behavior, and no merge-blocking risk was identified.

Pre-merge checks | Passed 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description check Passed The description clearly explains the Workers tests for the secure-cache AAD boundary, including the exact-limit and over-limit cases, wasm binding coverage, backend-call checks, and verification resul…
Title check Passed The title clearly identifies a Workers test that verifies the 64 KiB AAD boundary through the wasm binding. It is concise and directly related to the main change.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR

🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Oct 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@27Bslash6
27Bslash6 merged commit 58edbde into main Oct 12, 2026
14 checks passed
@27Bslash6
27Bslash6 deleted the agent/miss-huang/LAB-9108-wasm-aad-boundary branch October 12, 2026 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant