Add optional import validator to CssImportFilter - #51
Merged
Conversation
CssImportFilter resolves `@import` targets relative to the source stylesheet with `..` traversal allowed and no confinement, so a consumer that inlines imports from untrusted CSS can disclose any readable `.css` file on the server via path traversal. Add an opt-in `setImportValidator(callable)` hook. When set, the validator receives the resolved local import path and returns false to skip the import (leaving the raw `@import` statement untouched). It applies only to the local FileAsset branch — remote/HTTP imports are unaffected — and defaults to null, so existing behaviour is unchanged for callers that do not configure it. This lets a framework confine imports to allowed roots without Assetic taking a dependency on any particular path-resolution implementation. Relates to downstream advisory GHSA-2223-f22x-24cq (Winter CMS combiner LFI). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
TypeScript 7 removed the single-file `--outFile` option, so `TypeScriptFilter` failed with "error TS5102: Option 'outFile' has been removed" against current tsc (the CI matrix installs `typescript: *`). Compile into an output directory with `--outDir` and read the emitted `input.js` back instead. Also drops the now-unnecessary `--ignoreDeprecations` argument. Verified against tsc 7.0.2; full suite green. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Summary
CssImportFilterresolves@importtargets relative to the source stylesheet with..traversal allowed and no confinement, so a consumer that inlines imports from untrusted CSS can disclose any readable.cssfile on the server via path traversal.This adds an opt-in
setImportValidator(callable)hook. When set, the validator receives the resolved local import path and returnsfalseto skip the import (leaving the raw@importstatement untouched). It applies only to the localFileAssetbranch — remote/HTTP imports are unaffected — and defaults tonull, so existing behaviour is unchanged for callers that do not configure it.This lets a framework confine imports to allowed roots without Assetic taking a dependency on any particular path-resolution implementation.
Tests
Two new cases in
CssImportFilterTest(reject-all leaves@importuntouched; allow passes the resolved path and inlines as normal). 7/7 pass.Context
Supports the downstream fix for Winter CMS advisory GHSA-2223-f22x-24cq (asset combiner local file disclosure), where the JS and LESS importers are being confined to allowed roots and the CSS importer needs the same treatment via a caller-supplied validator.
🤖 Generated with Claude Code