Repository navigation
fix(security): apply one trust model to update and agents:md - #17
Merged
Merged
Conversation
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
force-pushed
the
fix/project-write-trust
branch
from
November 23, 2026 14:09
e409342 to
6f13152
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 tomainonce #16 is merged).agents:mdandproject:updatewroteAGENTS.md/CLAUDE.md,.gitignore,.sympress/project.jsonandcomposer.jsonthrough symlinks committed to an existing project, i.e. outside the project.name/versionfromcomposer.lockwent unchecked into the AGENTS.md index (a newline inversioninjected text agents read as instructions).repositoryUrls were written as unfiltered VCS repositories (canonical, before Packagist); with--no-installor no missing package without--allow-template-execution.project:updatehad no--manifest-sha256and loaded a remote JSON manifest unpinned beforecomposer update.project:update(also--dry-run) passed a localtemplateRepositoryUrlfrom the checked-in metadata togit -C <dir> show.sympress/mailer/sympress/nginx-cacheasdev-mainvia VCS although both are released on Packagist.Fix
ProjectPath::assertInside()resolves each write target (or its directory for new files) and refuses anything outsiderealpath($projectDir)and dangling links; used by all four writers. In-project links such asAGENTS.md -> CLAUDE.mdstill work.^[A-Za-z0-9._+-]{1,64}$(else the commit is shown)."only": [<packages>](create and update).project:updaterefuses any new catalog repository without--allow-template-execution, also with--no-install;--dry-runstill lists them.project:update --manifest-sha256, same rule asproject:create.https://,ssh://orgit@URLs; otherwise discovery is skipped with a note.--repository/--manifeston the command line still accept local paths.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-installandonly),testTrustedUpdateWithUnpinnedRemoteJsonManifestRequiresSha256,testManifestSha256MustMatchTheManifest,testLocalTemplateRepositoryFromMetadataIsNotOpenedWithGit(before the fix the planted manifest'sacme/plantedshowed up in the plan).Local QA:
composer tests(79 tests),static-analysis,cs,validate --strictgreen. Manual:bin/sympress update --dry-runagainst 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-installtrust gate, new--manifest-sha256option). CHANGELOG covers #16, this PR and the unreleasedci: let Dependabot update GitHub Actions pins. Tag/release after merge.