Skip to content

Add optional import validator to CssImportFilter - #51

Merged
LukeTowers merged 2 commits into
masterfrom
wip/ghsa-2223-css-import-validator
Jul 26, 2026
Merged

Add optional import validator to CssImportFilter#51
LukeTowers merged 2 commits into
masterfrom
wip/ghsa-2223-css-import-validator

Conversation

@LukeTowers

Copy link
Copy Markdown
Member

Summary

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.

This adds 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.

Tests

Two new cases in CssImportFilterTest (reject-all leaves @import untouched; 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

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>
@LukeTowers
LukeTowers merged commit 25dd5bc into master Jul 26, 2026
9 checks passed
@LukeTowers
LukeTowers deleted the wip/ghsa-2223-css-import-validator branch July 26, 2026 18:57
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