Skip to content

fix(api): refuse compressed request bodies instead of inflating them - #503

Merged
samuelmbabhazi merged 1 commit into
mainfrom
fix/api-refuse-compressed-bodies
Nov 25, 2026
Merged

samuelmbabhazi merged 1 commit into
mainfrom
fix/api-refuse-compressed-bodies

Conversation

@samuelmbabhazi

Copy link
Copy Markdown
Collaborator

What changed

The four body parsers (default JSON, large JSON, webhook raw, urlencoded) run with inflate: false. A request whose body has a Content-Encoding other than identity gets 415 problem details, before the body is read. SPEC 8.1 states the rule.

Why

CodeRabbit's review of #502 asked whether Node's own zstd copy was affected by CVE-2026-124851, given that the triage relied on it. It is.

  • The advisory covers zstd 1.5.1 through 1.5.7. Crafted compressed data can make decompressed output carry an internal 64 KiB buffer: uninitialized memory, or literals from earlier decompressions with the same context.
  • Node 22 bundles zstd 1.5.7 (process.versions.zstd in the published image).
  • body-parser 2.4.0 inflates Content-Encoding: zstd bodies with zlib.createZstdDecompress() when Node has it.
  • Checked on the published v0.1.0-alpha.5 installed in the lab: a project created with a zstd-compressed JSON body through the public HTTPS endpoint answered 201, with the decompressed fields stored and readable by the client.

No client of the API sends compressed bodies: the web UI, the CLI and GitHub's webhooks send plain bodies, and agents use gRPC. Refusing them removes that input path for zstd, and for Node's zlib and brotli as well.

Node's fetch (undici 6.29.1 in Node 22.23.5) does not decode zstd responses, checked against a local server. That was the other way zstd could be reached.

How it was tested

  • app.http.spec.ts: zstd, gzip, deflate and brotli bodies to the login route, to a large-JSON route (secrets) and to the webhook route each answer 415 with problem details. The test failed first, with 400.
  • The API unit suite passes (105 files, 902 tests), and so do api:lint and api:typecheck.

Security considerations

The released v0.1.0-alpha.5 has this exposure. Removing it from installations needs a new release with this change. Until then, a reverse proxy in front of the API can refuse compressed request bodies.

body-parser 2.4 inflates gzip, deflate, brotli and zstd bodies, so any request could make Node decompress zstd with its bundled zstd 1.5.7, which CVE-2026-124851 affects. No client sends compressed bodies: every parser now answers 415 before reading one.

Signed-off-by: samuel mbabhazi <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 11 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 5f49fb3 and 4f979c1.

Files selected for processing: 3

  • apps/api/src/app.http.spec.ts
  • apps/api/src/bootstrap.ts
  • docs/SPEC.md
  • 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

@samuelmbabhazi

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@samuelmbabhazi

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@samuelmbabhazi
samuelmbabhazi merged commit 928d6bf into main Nov 25, 2026
27 checks passed
@samuelmbabhazi
samuelmbabhazi deleted the fix/api-refuse-compressed-bodies branch November 25, 2026 22:01
samuelmbabhazi added a commit that referenced this pull request Nov 25, 2026
…ed (closes #480) (#502)

## What changed

The evidence #480 asks for, for the replacement release
`v0.1.0-alpha.5`.

- **`docs/security/image-triage-2026-11.md`, new section "Rescan of the
published v0.1.0-alpha.5 image".**
- Trivy 0.70.0, database of 2026-11-25 13:07 UTC, linux/amd64 and
linux/arm64, without the release gate's filters: 121 distinct
advisories, 1 critical, 11 high, none with a fix, no secret.
- One disposition per high or critical advisory, based on what the image
actually loads (checked in the published image):
    - every service runs `node` as `node`;
- `node` links only glibc and libstdc++, and bundles zlib 1.3.1 and zstd
1.5.7;
- argon2 is the only native addon, and links none of the flagged
packages;
- the `migrate` shim runs `readlink`, `uname` and `sed` on its own path;
- Node's bundled copies are checked against the same advisories. Its
zstd 1.5.7 is affected by CVE-2026-124851, and the API reached it in
alpha.5 through compressed request bodies. #503 removes that path. Its
zlib 1.3.1 is in CVE-2026-85091's range, but Node does not use the `gz*`
file functions where the flaw is (after CodeRabbit's review).
  - alpha.4 is named for what it is: same code, no image.
- **`docs/security/scans/control-plane-v0.1.0-alpha.5.json`.** The
findings per platform: id, severity, package, installed and fixed
versions. It also records the manifest digests, the scan command and the
database date, so the counts can be reproduced.
- **`docs/INSTALL.md`.**
- Status line and "What has been tested" for alpha.5: single-machine
install, deployment, logs and metrics, backup and restore, and the
upgrade from alpha.3 with a separate server.
  - Fixes the tests found:
- step 3 lists the first question, "Run applications on this machine
too?", and the organization;
- without a terminal, `--single-machine` and `--organization` are
needed, and `--smtp-from` and `--smtp-user` with SMTP. The documented
`--domain --email` form stopped at "Answer yes or no."; #499 makes the
installer say what is missing;
- **Upgrade:** take the backup after `docker compose pull`, with the new
bundle's `backup.sh`. Before that, an alpha.3 installation has neither
the `backup` service nor `backup.js` ("no such service: backup");
- **Upgrade:** agent upgrades exist now (#447, #448). An alpha.3 agent
makes the rollout stop with "not supported by this agent", and nothing
changes on its server;
- **Restore:** a deployment made after the backup makes the next
deployment fail once (#501).
- The bundle's provenance attestation is no longer "not tested": `gh
attestation verify` passed.

## Why

#480 asks for a replacement release after its checks, a rescan of the
exact new digests on every architecture with reproducible results, and
verification of startup, migrations, backups, Caddy routing, metrics and
logs, and the documented upgrade path.

## How it was tested

Everything in "What has been tested" was run on 25 November 2026, in
fresh Ubuntu 24.04 containers with systemd:

- the alpha.5 bundle downloaded and verified as the page says;
- the installer through a real terminal;
- the API flows over HTTPS;
- the upgrade from the published alpha.3 bundle, with an alpha.3 server
enrolled through the command and token copied from the Servers page.

The scan JSON comes from the published image by digest.

## Security considerations

No change to code or behavior. The scan file lists package versions
only, and no lab secret appears in any document.

Closes #480.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Documentation**
* Updated prerelease installation, deployment, backup, restore, and
upgrade guidance for alpha.5, including installer options and
requirements for noninteractive and SMTP-configured setups.
* Clarified restore behavior for deployments created after a backup,
agent upgrade procedures, and compatibility limitations.
* Expanded alpha.5 security guidance with platform-specific scan results
and details on compressed request handling.
* Updated testing results and clarified which upgrade scenarios have
been tested.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: samuel mbabhazi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant