Skip to content

[SECURITY] Contain and bound provider archive extraction #820

Open

Description

@jeffreyaven

Current ownership after the SDK migration

Archive extraction now belongs in StackQL internal/stackql/registry, including archive.go. No new omnisdk blocker is required for this host-owned implementation. Retain the old any-sdk source links as historical evidence.

Constituent of #769. Reviewed current main at 1de4135 on 2026-10-08; this issue proposes work, no implementation is included.

CWEs: CWE-22, CWE-770.

Finding and evidence

pkg/compression/compression.go joins target and the tar member name, then uses MkdirAll, os.Create and io.Copy without containment or size checks. internal/anysdk/registry.go invokes it during provider installation.

A current-dependency test created a five-byte tar member named ../sentinel.txt, extracted into a disposable child directory, and observed the file written in its parent with no error. This directly verifies traversal on Windows. The source also has no per-entry/aggregate expanded-size, entry-count or nesting limit.

The source is registry/archive content, not an ordinary SQL string. A compromised/untrusted registry, archive or transport under an explicitly insecure configuration is a prerequisite; no compromise of the official registry is alleged.

Required outcome

  • Reject members escaping the extraction root, absolute/drive/UNC names, unsafe member types and symlink/junction escapes. Use filesystem-safe containment, not only a lexical prefix check.
  • Bound entry count, entry size and aggregate expanded size, with configurable finite limits suitable for large providers.
  • Extract into staging, close all streams/files and activate only after validation succeeds; a rejected archive must not destroy the working provider version.

Validation and acceptance

StackQL registry tests should cover traversal on Windows/POSIX, existing symlinks, links/devices, truncated archives, decompression limits and safe nested directories. Add a stackql robot pull against a local malicious-archive fixture, asserting no outside writes and no partial provider activation.

Scope and related work

Fix belongs in StackQL's current registry archive implementation. Signature verification is independent: even trusted archives should not be able to escape the target or exhaust disk.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions