Repository navigation
web/elements: test that ak-mdx does not evaluate API-supplied content - #24524
Conversation
✅ Deploy Preview for authentik-storybook ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for authentik-integrations ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for authentik-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Render <ak-mdx> with content that calls a probe from an expression and from an ESM export, and assert the probe never runs, while Markdown still renders. Co-authored-by: Jan Kahmen <[email protected]>
57669f7 to
ee9ed81
Compare
|
This PR now targets Thanks @kah-ja for the report and the fix. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #24524 +/- ##
==========================================
- Coverage 92.38% 92.35% -0.04%
==========================================
Files 1190 1190
Lines 80153 80153
Branches 4351 4351
==========================================
- Hits 74048 74022 -26
- Misses 6039 6065 +26
Partials 66 66
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
* main: web/elements: test that ak-mdx does not evaluate API-supplied content (#24524)
…/sidebar-footer-dependency * web/sidebar/validate-sidebar-entries: The test exists and passes. Moving the load of the AdminOverviewPage to the entrypoint. The idea is to have the dashboard as live as possible as early as possible. Putting into Routes made Routes into a browser-only feature, and it could not be unit tested without this move. web/elements: test that ak-mdx does not evaluate API-supplied content (#24524)
…ts/sidebar-api-disconnect * web/elements/sidebar-footer-dependency: (27 commits) The test exists and passes. Moving the load of the AdminOverviewPage to the entrypoint. The idea is to have the dashboard as live as possible as early as possible. Putting into Routes made Routes into a browser-only feature, and it could not be unit tested without this move. web/elements: test that ak-mdx does not evaluate API-supplied content (#24524) root: require Node.js 24.22.1 (#27093) Formatter opinions. That side effect infected downstream tests. Darnit. web/admin: Simplify sidebar entries handling website/docs: change routing info after 2026.8 changes (#27109) core: bump astral-sh/uv from 0.13.4 to 0.13.5 in /lifecycle/container (#27096) flows: avoid saving plan history when inspector inaccessible (#27089) core: bump pyo3 from 0.29.0 to 0.30.1 (#27099) core: bump arc-swap from 1.9.2 to 1.9.3 (#27098) core: bump pyroscope-io from 1.2.5 to 1.3.0 (#27100) core: bump pyo3-build-config from 0.29.0 to 0.30.1 (#27097) core: bump dexidp/dex from v2.46.0 to v2.46.1 in /tests/e2e (#27095) website/integrations: VCF 9: touch up (#27094) lifecycle/container: add a distroless version of the server image (#26321) ci: run tests in the server image (#26510) packages/client-ts: Generate imports with `.js` extensions (#27029) core: bump djangorestframework from 3.18.1 to 3.18.3 (#26838) ...
|
🍒 Cherry-pick to |
…#24524) Render <ak-mdx> with content that calls a probe from an expression and from an ESM export, and assert the probe never runs, while Markdown still renders. Co-authored-by: Teffen Ellis <[email protected]>
…24524 to version-2026.8) (#27115) * web/elements: compile ak-mdx content from the API as CommonMark `<ak-mdx>` renders two kinds of source: documentation that is authored in-tree and bundled with the web interface (`url`), and content that comes back from the API (`content`) - user and group notes, and blueprint descriptions. Both were compiled as MDX. MDX evaluates expressions (`{...}`) and ESM imports/exports of a source when the compiled module runs, so API content was evaluated as code. The DOMPurify pass in front of the compiler works at the HTML level and does not see either construct. Compile `content` as CommonMark instead, so no part of it is evaluated, and keep MDX for the bundled documentation. Reported privately as GHSA-5vfm-49hj-h95w. * web/elements: test that ak-mdx does not evaluate API-supplied content (#24524) Render <ak-mdx> with content that calls a probe from an expression and from an ESM export, and assert the probe never runs, while Markdown still renders. Co-authored-by: Teffen Ellis <[email protected]> --------- Co-authored-by: Jan Kahmen <[email protected]> Co-authored-by: Jan Kahmen <[email protected]> Co-authored-by: Teffen Ellis <[email protected]>
|
🍒 Cherry-pick to |
…#24524) Render <ak-mdx> with content that calls a probe from an expression and from an ESM export, and assert the probe never runs, while Markdown still renders. Co-authored-by: Teffen Ellis <[email protected]>
…24524 to version-2026.5) (#27121) * web/elements: compile ak-mdx content from the API as CommonMark `<ak-mdx>` renders two kinds of source: documentation that is authored in-tree and bundled with the web interface (`url`), and content that comes back from the API (`content`) - user and group notes, and blueprint descriptions. Both were compiled as MDX. MDX evaluates expressions (`{...}`) and ESM imports/exports of a source when the compiled module runs, so API content was evaluated as code. The DOMPurify pass in front of the compiler works at the HTML level and does not see either construct. Compile `content` as CommonMark instead, so no part of it is evaluated, and keep MDX for the bundled documentation. Reported privately as GHSA-5vfm-49hj-h95w. * web/elements: test that ak-mdx does not evaluate API-supplied content (#24524) Render <ak-mdx> with content that calls a probe from an expression and from an ESM export, and assert the probe never runs, while Markdown still renders. Co-authored-by: Teffen Ellis <[email protected]> --------- Co-authored-by: Jan Kahmen <[email protected]> Co-authored-by: Jan Kahmen <[email protected]> Co-authored-by: Teffen Ellis <[email protected]>
|
We found this vulnerability during a penetration test at turingpoint. Thanks for the quick fix! The associated GitHub Security Advisory (GHSA-5vfm-49hj-h95w) can now be published. |
…single-shadowdom-sidebar * web/elements/sidebar-api-disconnect: (28 commits) Fix some merge issues. The test exists and passes. Moving the load of the AdminOverviewPage to the entrypoint. The idea is to have the dashboard as live as possible as early as possible. Putting into Routes made Routes into a browser-only feature, and it could not be unit tested without this move. web/elements: test that ak-mdx does not evaluate API-supplied content (#24524) root: require Node.js 24.22.1 (#27093) Formatter opinions. That side effect infected downstream tests. Darnit. web/admin: Simplify sidebar entries handling website/docs: change routing info after 2026.8 changes (#27109) core: bump astral-sh/uv from 0.13.4 to 0.13.5 in /lifecycle/container (#27096) flows: avoid saving plan history when inspector inaccessible (#27089) core: bump pyo3 from 0.29.0 to 0.30.1 (#27099) core: bump arc-swap from 1.9.2 to 1.9.3 (#27098) core: bump pyroscope-io from 1.2.5 to 1.3.0 (#27100) core: bump pyo3-build-config from 0.29.0 to 0.30.1 (#27097) core: bump dexidp/dex from v2.46.0 to v2.46.1 in /tests/e2e (#27095) website/integrations: VCF 9: touch up (#27094) lifecycle/container: add a distroless version of the server image (#26321) ci: run tests in the server image (#26510) packages/client-ts: Generate imports with `.js` extensions (#27029) ...
What
<ak-mdx>renders two kinds of source:url,content—user.attributes.notes(UserNotesCard.ts),group.attributes.notes(GroupViewPage.ts) and blueprint descriptions (BlueprintListPage.ts).Both were compiled with the same
compile()call, i.e. as MDX. MDX parses expressions ({...}), JSX and ESMimport/exportin addition to Markdown, and those are evaluated when the compiled module is run byrun()indelegateRender(). So a source that came from the API was evaluated as code in the admin interface.The
BrandedHTMLPolicyDOMPurify pass in front of the compiler does not cover this: it operates on HTML, and neither{...}nor anexportstatement is HTML — both reachcompile()unchanged.Reported privately as GHSA-5vfm-49hj-h95w.
Change
Thread the compile format through
delegateRender():url(bundled documentation) keepsformat: "mdx"— unchanged behaviour,content(from the API) getsformat: "md", i.e. CommonMark, so nothing in it is evaluated.This is a parser-level distinction rather than a filter, so it does not depend on enumerating constructs. The DOMPurify pass stays where it is.
Behaviour
Measured against the pinned versions (
@mdx-js/mdx3.1.1,dompurify3.4.12,react19.2.8), rendering through the samecompile()/run()pipeline the element uses:content{...}expressionexport const … = …import "data:text/javascript,…"<div>{…}</div>One intentional difference: raw HTML in
content(for example<strong>hi</strong>in a note) now renders as text instead of as an element. Markdown syntax is unaffected.Tests
web/src/elements/ak-mdx/content-format.unit.test.tscovers that a source is evaluated undermdxand inert undermd, and that CommonMark still renders.A note on running them locally:
web/vite.config.jspoints theUnit Testsproject at./tsconfig.unit.json, which is not in the tree, sovitest --project "Unit Tests"fails during transform before any test runs — including for the existingcustom-elements-get-name.unit.test.ts. I therefore ran the assertions of the new test as a plain node script againstweb/node_modules(all four pass) rather than through vitest. Happy to look at the missing tsconfig in a separate PR if that is useful.