Skip to content

test: restore example solvers - #68

Merged
hi-liang merged 2 commits into
mainfrom
test/example-solvers
Nov 17, 2026
Merged

hi-liang merged 2 commits into
mainfrom
test/example-solvers

Conversation

@hi-liang

@hi-liang hi-liang commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Build, deliver and solve every example on each PR

cork lost its example coverage when cmgr test went away (19e25e2, 4c81a10). Since then CI has built none of the corpus; the manual e2e builds four of the eight examples and runs one solver.

Changes

  • fix(build): every build-context entry is now owned by root. BuildKit (selected in 07b9d6e) keeps the owner a context file arrives with, so a plain COPY produced files owned by whoever owns the challenge tree on the build host, not root. The new check caught it: the multi-container example's sudoers file was ignored, so its solver hung. A unit test fails without the fix.

  • test(ci): ci/examples/run.sh runs as a new examples job (amd64 only). It starts a corkd on the runner's Docker daemon and, for each example:

    • builds it through the API
    • launches it if it's a service, or checks a launch is refused if it isn't
    • runs its own solver, which must write the build's flag
    • stops the instance and destroys the build

    Only a flag-only challenge may lack a solver. The disks base image is built through the Actions cache.

  • examples/solvers.md now describes the contract as it runs. pwntools was never preinstalled, and metadata.json was undocumented.

Verification

On Docker 29.10.0, all 8 examples pass in about 3 min. Without the fix, the multi-container example's solver times out.

Not addressed here: build ids are reused after a destroy (builds has no AUTOINCREMENT). That will be a separate PR.

createBuildContext writes each challenge file with tar.FileInfoHeader,
which records the owner the file has on the build host. The classic
builder ignored that: a Dockerfile COPY without --chown always produced
files owned by root. BuildKit, selected explicitly since 07b9d6e, keeps
the owner the context entry carries, so since then every plain COPY in
a cork-built image has been owned by whoever owns the challenge tree
where it was built, not by root.

Found by the examples check that follows: the multi-container example
installs a sudoers drop-in with a plain COPY, sudo refuses a drop-in
not owned by root ("owned by uid 1000, should be 0"), and its solver
waited at a password prompt until it timed out.

Every context entry now says root, as artifact archives already do.
Nothing hashes the context's headers, so this changes no build's
identity: an image built since 07b9d6e keeps its owners until its
challenge is rebuilt for another reason.
`cmgr test --require-solve examples` used to do this in CI. It went with
the in-process CLI in 19e25e2, its CI step followed in 4c81a10, and since
then nothing built most of the corpus: the e2e fleet builds four of the
eight examples, by hand, and runs one solver.

ci/examples/run.sh starts a corkd on the runner's own docker daemon (no
registry, no workers) and, for every challenge it finds:

- builds it through POST /challenges/<id>
- checks the recorded flag, and that a build publishing artifacts left a
  readable archive in the artifact directory
- for a service, launches it as the platform does (user_id and env),
  runs its solver on the instance's network, then stops it and checks
  its containers and network are gone
- for artifact-only and flag-only, checks a launch is refused and runs
  the solver on the default network
- destroys the build

The solver runs the way examples/solvers.md describes, which this
rewrites to match: solver/ plus the extracted artifacts and lookup
values, in the default image ci/examples/solver.Dockerfile unless it
brings its own, under cork's seccomp policy, and must write the build's
flag within ten minutes. A challenge without a solver fails unless it is
flag-only.

It runs as a job of its own in go.yml, amd64 only, against a
docker:$DOCKER_ENGINE-dind engine (29.10.0, what production runs, with
overlay2 as production configures it) rather than the runner's own,
which lags it: an engine before 29.6.0 cannot pull a base image for a
build with no client session, which is how cork builds
(moby/moby#48112; 29.4.3 and 29.5.3 fail, 29.6.0 to 29.10.0 build, the
runner shipped 29.4.2). The e2e never met this because its builder is a
pinned dind too. The disks example's base image is built through the
Actions cache on the runner and handed to that engine.

Checked on Docker Desktop 29.9.3 and on a cold docker:29.10.0-dind
engine set up as the job sets it up (189 s): all eight examples pass
with the ownership fix; without it the multi-container example's solver
hangs at sudo's password prompt.
@hi-liang
hi-liang force-pushed the test/example-solvers branch from 46d781f to 80b05b7 Compare November 17, 2026 18:08
@hi-liang
hi-liang merged commit 40c946c into main Nov 17, 2026
5 checks passed
@hi-liang
hi-liang deleted the test/example-solvers branch November 25, 2026 03:43
hi-liang added a commit that referenced this pull request Nov 25, 2026
Covers what landed since v1.3.0: preloading (#55), difficulty in problem.md (#62), single-certificate re-issue (#54), the module path rename (#60), worker-down across a restart (#63), the public address in the schema state (#75) and root-owned COPY (#68). Dependency bumps and CI/e2e upkeep are left out, as before.
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