Skip to content

Validate container ID from XPC requests - #1956

Merged
katiewasnothere merged 2 commits into
apple:mainfrom
katiewasnothere:validate_xpc_containerid
Jul 20, 2026
Merged

Validate container ID from XPC requests#1956
katiewasnothere merged 2 commits into
apple:mainfrom
katiewasnothere:validate_xpc_containerid

Conversation

@katiewasnothere

Copy link
Copy Markdown
Contributor

Type of Change

  • Bug fix

Motivation and Context

Validate XPC message provided container IDs in ContainersHarness to prevent file path traversal when container ID is invalid.

Testing

  • Tested locally

@github-actions github-actions Bot added the cli label Jul 16, 2026
@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown

Code Coverage

Tier Line Coverage
Unit 23.4%
Integration 66.62%
Combined 75.53%

Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
@katiewasnothere
katiewasnothere force-pushed the validate_xpc_containerid branch from 8ca584c to 12d7472 Compare July 16, 2026 21:08
/// Utility.validEntityName
/// Container name rule
public static func nameValid(_ name: String) -> Bool {
guard name.count < 63 else {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
guard name.count < 63 else {
// Maximum Linux hostname length is 64, but limit to maximum DNS label length
guard name.count =< 63 else {

Do we have a unit test that checks the length constraint?

@katiewasnothere
katiewasnothere force-pushed the validate_xpc_containerid branch from 9ec5fee to 2ec268f Compare July 16, 2026 21:51
Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
@katiewasnothere
katiewasnothere force-pushed the validate_xpc_containerid branch from 2ec268f to 6e1c195 Compare July 17, 2026 18:53
@katiewasnothere
katiewasnothere merged commit 9e1d6e8 into apple:main Jul 20, 2026
3 checks passed
@katiewasnothere
katiewasnothere deleted the validate_xpc_containerid branch July 20, 2026 17:42
@jglogan jglogan mentioned this pull request Jul 20, 2026
7 tasks
benoitf added a commit to socktainer/socktainer that referenced this pull request Jul 30, 2026
….40.1

Bump apple/container from 1.1.0 to 1.2.0 and apple/containerization
from 0.35.0 to 0.40.1 (required by container 1.2.0).

Adapt to upstream API changes:

- `Utility.validEntityName` was removed (apple/container#1956);
  replaced with `ManagedContainer.nameValid` from ContainerResource.
- `Builder(socket:group:logger:)` is now async; added `await`.
- `ContainerNameUtility.maxLength` reduced from 64 to 63 to match
  the DNS label limit enforced by `ManagedContainer.nameValid`.

Signed-off-by: Florent Benoit <fbenoit@redhat.com>

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Florent Benoit <fbenoit@redhat.com>
andrewkomkov added a commit to getgantry/gantry that referenced this pull request Aug 1, 2026
…ot args (#14)

apple/container **1.2.0** is out (previously tracked: `1.1.0`).

Upstream notes: https://github.com/apple/container/releases/tag/1.2.0 —
mirrored in `docs/upstream/apple-container-1.2.0.md`.

## Review checklist

- [ ] New or changed CLI flags Gantry should surface (`container
run/create/machine/build`)
- [ ] Changed `--format json` shapes the DockerKit apple transport
decodes
- [ ] Fixed upstream bugs Gantry currently works around
- [ ] `ContainerTooling.recommendedVersion` / feature gates need moving
to `1.2.0`
- [ ] MCP tools and App Intents that expose the affected commands
- [ ] README and CHANGELOG entries for whatever is adopted

Merging records the version as reviewed. Implement the adopted parts on
this branch, or merge as-is and open follow-ups.

---

<details><summary>Upstream release notes</summary>

## What's Changed
* Add TestCLISystemLogs and TestCLITermIO integration tests in new
integration test suite by @katiewasnothere in
apple/container#1879
* Restore reverted migrations, migrate last tests. by @jglogan in
apple/container#1880
* Removes obsolete CLITests directory. by @jglogan in
apple/container#1886
* Integration coverage xpc helpers by @noah-thor in
apple/container#1551
* Upgrade grpc-swift-nio-transport to 2.9.0 and remove HTTP2ConnectBuff…
by @adityabagchi24 in apple/container#1790
* Updates containerization to 0.36.0. by @jglogan in
apple/container#1912
* Use containerization version 0.37.0 by @adityaramani in
apple/container#1932
* Verify kernel archive integrity by @haoruilee in
apple/container#1703
* Add commit/issue alert to PR template. by @jglogan in
apple/container#1945
* Remove `--skip-build` from test Makefile target. by @jglogan in
apple/container#1951
* Restore `--skip-build`, enable `import testable` for release builds.
by @jglogan in apple/container#1955
* [package]: bump container-builder-shim to 0.13.0 by @saehejkang in
apple/container#1953
* Validate container ID from XPC requests by @katiewasnothere in
apple/container#1956
* Remove force unwraps on XPC error set/get by @katiewasnothere in
apple/container#1958
* Do not follow destination symlink when copying user configuration by
@katiewasnothere in apple/container#1957
* Fix machine ID length test. by @jglogan in
apple/container#1971
* Address flaky TestCLIKernelSetSerial suite. by @jglogan in
apple/container#1976
* [gitignore]: ignore vscode workspace files by @saehejkang in
apple/container#1966
* Update containerization dependency with new EXT4Unpacker func
definition by @katiewasnothere in
apple/container#1973
* Periodic dependency updates. by @jglogan in
apple/container#1981
* Use ordered journal mode for unpacked images. by @jglogan in
apple/container#1974
* Reword DNS container name resolution doc information by
@katiewasnothere in apple/container#1960
* ci: bump the github-actions group across 1 directory with 3 updates by
@dependabot[bot] in apple/container#1983
* Pass build config in when building protoc dependencies by
@katiewasnothere in apple/container#1972
* Container test fixture package by @katiewasnothere in
apple/container#1887
* Downgrade swift-collections to 1.5.1. by @jglogan in
apple/container#1984
* Use `enum` for warmup images. by @jglogan in
apple/container#1990
* Add missing dependencies to new ContainerTestSupport package by
@katiewasnothere in apple/container#1994
* Add OCI maskedPaths and readonlyPaths support to Container API. by
@jglogan in apple/container#1996
* Integration test - miscellaneous fixture and test refinements. by
@jglogan in apple/container#1993
* Use log instead of print for system start status messages by
@adityabagchi24 in apple/container#1889
* Fix BuilderStart race, parallelize `container build` tests. by
@jglogan in apple/container#2002
* Allow custom kernel boot args via --kernel-arg by @arirubinstein in
apple/container#1744
* fix: Increase XPC timeout for Machine API operations by @dev-kvt in
apple/container#2006
* Update containerization import to latest 0.40.0 by @katiewasnothere in
apple/container#2028
* Fix image env vars, build context checks, TCP/UDP port forward buffer,
and validate plugin name by @katiewasnothere in
apple/container#2027
* Update containerization import to 0.40.1 by @katiewasnothere in
apple/container#2038

## New Contributors
* @haoruilee made their first contribution in
apple/container#1703
* @arirubinstein made their first contribution in
apple/container#1744
* @dev-kvt made their first contribution in
apple/container#2006

**Full Changelog**:
apple/container@1.1.0...1.2.0

</details>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Andrew <Andrew.Komkov@gmail.com>
henrywang added a commit to henrywang/Berthly that referenced this pull request Aug 4, 2026
## Summary
- Bumps the `container` SPM pin (1.1.0 → 1.2.0, `upToNextMinorVersion`)
and its transitive `containerization` dependency (→ 0.40.1).
- Adapts the three call sites that used the removed
`Utility.validEntityName` to `ManagedContainer.nameValid(_:)`, the same
replacement upstream made in
[apple/container#1956](apple/container#1956)
(name validation moved server-side into XPC request handling).
- Awaits `ContainerBuild.Builder.init`, which became `async` in 1.2.0.
- Satisfies the new `Flags.Management.kernelArgs: [String]` parameter
with `[]` — no behavior change; surfacing `--kernel-arg` in the
Run/Create sheet is tracked separately.

## Why
apple/container 1.2.0 shipped 2026-07-29. Berthly's `Package.resolved`
was still pinned to 1.1.0/0.35.0, and `PARITY.md` is explicitly audited
against 1.1.0. First step of the `v1.2.0` milestone (#75) — everything
else in that milestone (`ContainerCompatibility.requiredVersion` sync,
`PARITY.md` refresh, `--kernel-arg` UI, kernel digest verification) is
blocked on this landing.

Closes #75

## Test plan
- [x] `xcodebuild build` succeeds
- [x] `xcodebuild test -only-testing:BerthlyTests` — full suite passes
- [x] `swiftlint lint --strict` — 0 violations
TakiTake added a commit to TakiTake/pall8t that referenced this pull request Aug 8, 2026
apple/container 1.2.0 rejects any container name over 63 characters
(ManagedContainer.nameValid, apple/container#1956) and `container run`
checks it client-side before launching, so a workspace whose basename
pushed `pall8t-<slug>-<hash>-<pid>` past the cap failed outright with
"container ID ... is not a valid container ID" where 1.0.0 had run it.

Cap the slug at 32 characters inside `path_key` — the one seam shared by
container names, image tag bases, and reference-repo clone dirs, so the
three can't drift — leaving 14 digits of pid headroom. The 8-hex path
hash already carries uniqueness, so a shortened slug costs readability
and nothing else.

The regression pin transcribes upstream's whole rule (length *and*
shape) as a test oracle, so a future name change is checked against what
apple/container actually enforces rather than against the length alone.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
TakiTake added a commit to TakiTake/pall8t that referenced this pull request Aug 8, 2026
apple/container 1.2.0 rejects any container name over 63 characters
(ManagedContainer.nameValid, apple/container#1956) and `container run`
checks it client-side before launching, so a workspace whose basename
pushed `pall8t-<slug>-<hash>-<pid>` past the cap failed outright with
"container ID ... is not a valid container ID" where 1.0.0 had run it.

Cap the slug at 32 characters inside `path_key` — the one seam shared by
container names, image tag bases, and reference-repo clone dirs, so the
three can't drift — leaving 14 digits of pid headroom. The 8-hex path
hash already carries uniqueness, so a shortened slug costs readability
and nothing else.

The regression pin transcribes upstream's whole rule (length *and*
shape) as a test oracle, so a future name change is checked against what
apple/container actually enforces rather than against the length alone.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants