Skip to content

fix(maker): harden maker inputs from audit Low findings - #9

Merged
brianvarskonst merged 5 commits into
mainfrom
fix/low-audit-findings
Nov 16, 2026
Merged

brianvarskonst merged 5 commits into
mainfrom
fix/low-audit-findings

Conversation

@brianvarskonst

Copy link
Copy Markdown
Member

Problem

The 2026-11-15 audit reported four Low findings in generator input handling (exploitable by whoever feeds the maker commands, e.g. scripts or coding agents passing ticket text):

  1. make:data-provider --method was rendered verbatim into the skeleton, allowing arbitrary PHP in the generated class.
  2. make:asset-entry --path had no traversal check: PackageContext::packageRelativePath() only stripped leading slashes, so Resources/../../../x.ts wrote outside the package and project.
  3. make:asset-entry --handle was written raw into a // / /* */ comment in the generated TS/SCSS file; a newline or */ broke out of it.
  4. make:block silently overwrote an existing block.json, editor/frontend entry and view (Generator::dumpFile() has no existence check).

Fix

  • MakeDataProvider: validate the method with SourceLiteral::identifier(), as MakeHook does.
  • PackageContext::packageRelativePath(): pass the result through ProjectPath::relative() (rejects .. segments, absolute paths, NUL and symlink escapes; same guard as make:sympress-package --path). This covers every caller (make:asset-entry, make:block).
  • MakeAssetEntry: accept only handles matching ^[a-z0-9][a-z0-9_-]*$ (WordPress handle convention); applies to explicit and derived handles.
  • MakeBlock: fail with The file "…" can't be generated because it already exists. (same wording/behaviour as MakerBundle's generateClass()) before queuing any write. No --force was added since no such pattern exists in the bundle.

All checks run before writeChanges(), so a rejected run writes nothing.

Behaviour note: a package whose directory is a symlink pointing outside the project root can no longer receive generated asset/block files (it is treated as an escape).

Tests

New tests/Maker/MakerInputSafetyTest.php runs the makers end to end against a temp workspace. Each test was verified to fail on main and pass with the fix:

  • data-provider injection payload → InvalidArgumentException, nothing written
  • --path=Resources/../../../escape.ts → rejected, no file outside the package, no webpack config
  • handles with \n and */ → rejected
  • existing block.json → refused and preserved; after removing it the block (incl. view) generates normally

Local QA (PHP 8.5 container): composer validate --strict valid, composer cs OK, composer static-analysis no errors, composer tests OK (23 tests, 176 assertions).

Release

Patch: 1.0.4 (CHANGELOG entry, includes the unreleased CI pin to sympress/workflows v1.3.2). Tag v1.0.4 / release title v1.0.4 after merge.

The --method option was rendered verbatim into the data provider
skeleton, so a crafted value could inject arbitrary PHP into the
generated class. Validate it as a PHP identifier like make:hook does.
PackageContext::packageRelativePath() only stripped leading slashes, so
make:asset-entry --path=Resources/../../../x.ts wrote outside the
package and project. Run the result through ProjectPath::relative(),
which rejects traversal segments, absolute paths and symlink escapes,
as make:sympress-package --path already does.
The handle was written verbatim into a // or /* */ comment of the
generated TS/SCSS entry, so a newline or "*/" could inject code.
Accept only the WordPress handle convention (lowercase letters, digits,
"-" and "_"), which also covers handles derived from the entry name.
Generator::dumpFile() has no existence check, so re-running make:block
after renaming or deleting the block class silently replaced a
maintained block.json, editor/frontend entry and view template. Fail
like generateClass() does when one of these files already exists.
@brianvarskonst
brianvarskonst merged commit 44bb411 into main Nov 16, 2026
3 checks passed
@brianvarskonst
brianvarskonst deleted the fix/low-audit-findings branch November 16, 2026 14:12
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