Skip to content

fix(security): apply one trust model to update and agents:md - #17

Merged
brianvarskonst merged 7 commits into
mainfrom
fix/project-write-trust
Nov 23, 2026
Merged

brianvarskonst merged 7 commits into
mainfrom
fix/project-write-trust

Conversation

@brianvarskonst

Copy link
Copy Markdown
Member

Problem

Findings #3–#7 and #10 of the Fable re-audit (2026-11-22). Stacked on #16 (base fix/default-starter-pin; GitHub retargets it to main once #16 is merged).

Fix

  • ProjectPath::assertInside() resolves each write target (or its directory for new files) and refuses anything outside realpath($projectDir) and dangling links; used by all four writers. In-project links such as AGENTS.md -> CLAUDE.md still work.
  • Lock names must match the Composer package-name pattern (else skipped); versions must match ^[A-Za-z0-9._+-]{1,64}$ (else the commit is shown).
  • Repositories are written with "only": [<packages>] (create and update). project:update refuses any new catalog repository without --allow-template-execution, also with --no-install; --dry-run still lists them.
  • project:update --manifest-sha256, same rule as project:create.
  • Metadata repositories are only used for discovery when they are https://, ssh:// or git@ URLs; otherwise discovery is skipped with a note. --repository/--manifest on the command line still accept local paths.
  • mailer/nginx-cache use the default constraint from Packagist; the built-in catalog adds no VCS repositories, so repositoryUrls() is removed.

Tests

Regression tests, each verified to fail without its fix: AgentsDocsWriterTest::testIndexFollowsLinksInsideButNotOutsideTheProject, ProjectPathTest (writers refuse links out of the project, dangling links), AgentsDocsWriterTest::testFindsOnlySymPressPackagesPinnedToACommit (injected version/name), UpdateProjectCommandTest::testComposerUpdateWithNewCatalogRepositoryRequiresTrust (now also --no-install and only), testTrustedUpdateWithUnpinnedRemoteJsonManifestRequiresSha256, testManifestSha256MustMatchTheManifest, testLocalTemplateRepositoryFromMetadataIsNotOpenedWithGit (before the fix the planted manifest's acme/planted showed up in the plan).

Local QA: composer tests (79 tests), static-analysis, cs, validate --strict green. Manual: bin/sympress update --dry-run against a project at Starter 1.2.5 still discovers the GitHub manifest at the pinned SHA.

Release

chore(release): prepare 0.4.0 (minor: CLI behaviour changes: new default template, --no-install trust gate, new --manifest-sha256 option). CHANGELOG covers #16, this PR and the unreleased ci: let Dependabot update GitHub Actions pins. Tag/release after merge.

@brianvarskonst
brianvarskonst changed the base branch from fix/default-starter-pin to main November 23, 2026 14:09
agents:md and project:update write into an existing, checked-in project:
AGENTS.md/CLAUDE.md, .gitignore, .sympress/project.json and
composer.json. Symfony's dumpFile() and file_put_contents() follow
symlinks, so a link committed to a shared project (e.g. AGENTS.md ->
~/.bashrc) made these commands append to or replace files outside the
project with the developer's permissions. The 0.2.0 fix only covered
the checkout in project:create.

All four writers now resolve the target (or its directory for a new
file) and stop unless it stays inside the project directory. Dangling
links are refused. Links within the project, such as AGENTS.md ->
CLAUDE.md, keep working.
agents:md copied the name and version of each SymPress package from
composer.lock into the index block of AGENTS.md/CLAUDE.md unchecked. A
line break in the version field wrote arbitrary text into the file that
coding agents read as instructions.

Names must now match the Composer package-name pattern, otherwise the
package is skipped; versions must match ^[A-Za-z0-9._+-]{1,64}$,
otherwise the installed commit is shown instead.
Manifest repositoryUrls were added to composer.json as unfiltered VCS
repositories. Composer treats such repositories as canonical and before
Packagist, so the repository could later serve any package, including
sympress/*. With --no-install, or when no package was missing,
project:update wrote them without --allow-template-execution, and the
error message even recommended that path.

Repositories are now written with "only": [<packages they were added
for>], in project:create and project:update. project:update refuses to
add a repository outside the built-in catalog without
--allow-template-execution, also with --no-install; --dry-run still
lists it.
0.3.0 required --manifest-sha256 for setup with a remote JSON manifest
in project:create only. project:update --manifest=https://.../x.json
--allow-template-execution still loaded the file unpinned and used its
repositories for composer update, and the option did not exist there.

project:update now has --manifest-sha256 and applies the same rule:
trusting a remote JSON manifest outside --dry-run requires the SHA-256
of the reviewed file, and a given hash must match the loaded manifest.
project:update, also with --dry-run, passed templateRepositoryUrl from
the checked-in .sympress/project.json to git ls-remote and, for a local
directory, to `git -C <dir> show`. Git reads the configuration of that
directory, so a repository planted in a shared project could feed a
catalog (and possibly Git config) into an update the developer only
meant to inspect.

A repository taken from the metadata is now only used for manifest
discovery when it is an https://, ssh:// or git@ URL. Otherwise the
update skips discovery and says so; --repository or --manifest given
on the command line still accept local paths.
The built-in catalog required sympress/mailer and sympress/nginx-cache
as dev-main through VCS repositories. Both have tagged releases on
Packagist, and the Starter manifest lists them without a repository, so
offline updates (--no-remote-manifest) pinned projects to untagged main.

Both now use the catalog default constraint without a repository. The
built-in catalog therefore adds no VCS repositories, and project:update
requires --allow-template-execution for every catalog repository.
@brianvarskonst
brianvarskonst force-pushed the fix/project-write-trust branch from e409342 to 6f13152 Compare November 23, 2026 14:09
@brianvarskonst
brianvarskonst merged commit 8df630e into main Nov 23, 2026
2 checks passed
@brianvarskonst
brianvarskonst deleted the fix/project-write-trust branch November 23, 2026 14:11
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