Skip to content

fix(cli): harden uteke upgrade (tag chars, download size cap, archive path check) (#1421) - #1422

Merged
ajianaz merged 2 commits into
developfrom
fix/upgrade-hardening-1327
Oct 9, 2026
Merged

ajianaz merged 2 commits into
developfrom
fix/upgrade-hardening-1327

Conversation

@ajianaz

@ajianaz ajianaz commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

What

Hardens uteke upgrade (crates/uteke-cli/src/commands/upgrade.rs), the signature-independent part of #1327:

  1. Tag chars: is_valid_version_tag now requires the whole tag (suffix too) to be [0-9A-Za-z.-] and a single optional leading v (it used to trim any number of vs and never look at the suffix, so v1.2.3-../x passed). run() re-validates the tag right before it is used in the URL and file name.
  2. Size cap: archive capped at 128 MiB (the v0.20.1 archives are 22-35 MiB, so more than 3x headroom over the largest), checksums-sha256.txt at 1 MiB. Enforced while streaming (copy_capped, reads at most max+1 bytes) so a missing or lying Content-Length cannot bypass it; check_declared_len also rejects early from the header.
  3. Archive path check: contains("..") replaced by is_safe_archive_path, which accepts only Normal/CurDir components (rejects absolute, prefix and any .. component). Existing layouts (uteke, ./uteke, libonnxruntime*) still pass; names like a..b, wrongly refused before, are now accepted.
  4. UTEKE_UPGRADE_SKIP_CHECKSUM: kept, but the warning is now a multi-line stderr banner stating the archive is not verified and will be executed as-is. Owner decision needed: keep or remove this escape hatch (with signature verification coming, it may no longer be justified).

Not included: signature verification (needs the first signed release to pin the certificate identity), workflow and SECURITY.md changes.

Why

The unchecked tag suffix flowed into a URL and a file name, the download was unbounded, and the traversal check was substring-based. See #1327 / #1421.

Testing

New unit tests: tag suffix restriction (fails against the old validator, which accepted v1.2.3-../x), copy_capped with exact/over-limit bodies and no Content-Length (stops at max+1), check_declared_len, component-based path check. No network in tests.
The other tests exercise new helper functions, so they cannot pass without the change; the real streaming download was not run (no network in the session), only the pure helpers are covered.
cargo fmt --all --check, cargo clippy --workspace --all-targets -- -D warnings, cargo test --workspace all pass.

Refs #1327
Closes #1421

🤖 Generated with Claude Code

… path check) (#1421)

- restrict the version tag to [0-9A-Za-z.-] (suffix included) and re-check it before building the URL/file name
- cap the archive (128 MiB) and checksums file (1 MiB) while streaming and from Content-Length
- component-based archive entry path check instead of contains("..")
- stronger UTEKE_UPGRADE_SKIP_CHECKSUM warning

Refs #1327

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

@ajianaz
ajianaz merged commit 57c5278 into develop Oct 9, 2026
18 checks passed
@ajianaz
ajianaz deleted the fix/upgrade-hardening-1327 branch October 9, 2026 09:45
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.

fix(cli): harden uteke upgrade (tag chars, download size cap, archive path check) (#1327)

1 participant