8000 Fix medium-severity npm transitive dependency vulnerabilities via pnpm overrides by abstractj · Pull Request #47658 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

Fix medium-severity npm transitive dependency vulnerabilities via pnpm overrides - #47658

Closed
abstractj wants to merge 1 commit into
keycloak:mainfrom
abstractj:medium-severity
Closed

abstractj wants to merge 1 commit into
keycloak:mainfrom
abstractj:medium-severity

Conversation

@abstractj
Copy link
Copy Markdown
Contributor

Apply pnpm.overrides to force patched versions of vulnerable transitive dependencies where no upstream fix is available from direct dependencies:

  • brace-expansion ^1 → ^1.1.13 (process hang and memory exhaustion) via eslint 9.x → minimatch 3.x

  • brace-expansion ^2 → ^2.0.3 (process hang and memory exhaustion) via typescript-eslint → minimatch 9.x

  • ajv ^6 → ^6.14.0 (ReDoS when using $data option) via eslint 9.x → @eslint/eslintrc

  • ajv ^8 → ^8.18.0 (ReDoS when using $data option) via vite-plugin-dts → @microsoft/api-extractor

  • lodash → ^4.17.23 (Prototype Pollution in _.unset and _.omit) via @patternfly/react-table, eslint-plugin-lodash, @microsoft/api-extractor

  • mdast-util-to-hast → ^13.2.1 (unsanitized class attribute) via @uiw/react-textarea-code-editor → rehype chain

  • jquery ^3 → ^3.5.0 (XSS vulnerabilities) via patternfly@3.59.5 in themes-vendor

Not addressed: bootstrap 3.4.1 (no patched version exists, pulled by EOL patternfly@3.59.5).

Note: These changes were created with the assistance of AI and reviewed before
submission.

@ssilvert
ssilvert commented Apr 6, 2026
Copy link
Copy Markdown
Contributor

@abstractj FYI. There are test failures.

@abstractj
abstractj force-pushed the medium-severity branch 3 times, most recently from 79d713d to 7a823e8 Compare April 9, 2026 21:02
@abstractj
abstractj force-pushed the medium-severity branch 2 times, most recently from f78d95f to 0c0fa94 Compare April 22, 2026 19:39
…m overrides

Apply pnpm.overrides to force patched versions of vulnerable transitive
dependencies where no upstream fix is available from direct
dependencies:

- brace-expansion ^1 → ^1.1.13 (process hang and memory exhaustion)
  via eslint 9.x → minimatch 3.x

- brace-expansion ^2 → ^2.0.3 (process hang and memory exhaustion)
  via typescript-eslint → minimatch 9.x

- ajv ^6 → ^6.14.0 (ReDoS when using $data option)
  via eslint 9.x → @eslint/eslintrc

- ajv ^8 → ^8.18.0 (ReDoS when using $data option)
  via vite-plugin-dts → @microsoft/api-extractor

- lodash → ^4.17.23 (Prototype Pollution in _.unset and _.omit)
via @patternfly/react-table, eslint-plugin-lodash,
@microsoft/api-extractor

- mdast-util-to-hast → ^13.2.1 (unsanitized class attribute)
  via @uiw/react-textarea-code-editor → rehype chain

- jquery ^3 → ^3.5.0 (XSS vulnerabilities)
  via patternfly@3.59.5 in themes-vendor

Not addressed: bootstrap 3.4.1 (no patched version exists, pulled by
EOL patternfly@3.59.5).

Signed-off-by: Bruno Oliveira da Silva <bruno@abstractj.com>
@ahus1 ahus1 self-assigned this Apr 23, 2026
@ahus1
ahus1 commented Apr 23, 2026
Copy link
Copy Markdown
Member

@ssilvert / @edewit - the CI is now green. Can you please double-check the changes before I merge them?

@ssilvert ssilvert left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a lot of seemingly unrelated changes here. Does the AI say they are needed to go along with the overrides?

@ahus1
ahus1 commented Apr 23, 2026
Copy link
Copy Markdown
Member

@ssilvert - I remember that those changes were related to some of the implicit eslint upgrades which now enforced stricter handling.

@ssilvert
Copy link
Copy Markdown
Contributor

@ssilvert - I remember that those changes were related to some of the implicit eslint upgrades which now enforced stricter handling.

OK. That makes sense.

@ssilvert
Copy link
Copy Markdown
Contributor

@ssilvert - I remember that those changes were related to some of the implicit eslint upgrades which now enforced stricter handling.

OK. That makes sense.

Actually, it doesn't make sense. Some of those changes don't seem to be related to new eslint rules.

@ssilvert
Copy link
Copy Markdown
Contributor

Here is what Claude Code had to say:

Code Review: PR #47658 — Fix medium-severity npm transitive dependency vulnerabilities

Overview
The PR aims to add pnpm.overrides for 6–7 vulnerable transitive dependencies. However, the diff also contains ~10 unrelated TypeScript/source code changes, Prettier reformatting, test assertion modernization, and an architecture change to KeycloakContext. This makes the PR significantly broader than its title suggests.

Issues

1. Wrong lodash version override (bug)

[js/package.json:286] sets "lodash": "^4.18.1", but the PR description says the target is ^4.17.23. Lodash's highest published version is 4.17.21 — there is no 4.18.x. The range ^4.18.1 (meaning >=4.18.1 <5.0.0) will never resolve to a valid version and will cause pnpm install to fail or silently skip the override. This is the most critical bug in the PR.

2. Overrides promised in description are missing from code

The PR description lists these overrides, but they are absent from [js/package.json]

brace-expansion ^1 → ^1.1.13
brace-expansion ^2 → ^2.0.3
ajv ^6 → ^6.14.0
Only ajv@^8 was added. Either these were already present before and should be noted as such, or they were dropped accidentally.

3. Unrelated source code changes bundled with security fixes

Security vulnerability PRs should contain only the overrides and lockfile update. The following changes are unrelated and increase review surface area and regression risk:

FlowDetails.tsx:208 — removes description = "" default; if callers of addFlowToFlow depend on a defined description, this silently passes undefined to the API
ClientScope.tsx:36 — removes scopes = [] default; if useFetch's callback fires with undefined/null, the subsequent .find() call will throw
ConfirmDialog.tsx:79 — removes open = true default; any callers that omit open will now see the dialog hidden by default instead of visible — a silent behavioral regression
RealmLoAMapping.tsx:93 — removes uri = false default; callers that rely on the default now get undefined instead of false for a boolean prop
Multiple Prettier reformatting changes (interface extends, import wrapping)

4. KeycloakContext.tsx architecture change

js/libs/ui-shared/src/context/KeycloakContext.tsx replaces a per-provider lazy-initialized generic context with a single module-level createContext<KeycloakContext>. While fixing the anti-pattern of calling createContext in the render function is correct, the new design loses generic type safety (replaced by as casts). More importantly, it means all KeycloakProvider instances share a single context, which could be a breaking change if multiple providers with different environment types are used (e.g., admin-ui and account-ui loaded together). This deserves its own focused PR with explicit justification.

5. AI-generated changes acknowledged but not fully verified

The PR description states it was AI-generated and reviewed before submission. The lodash version bug (#1 above) suggests that review was incomplete. Given the large number of lock file changes and source changes, a thorough manual verification is warranted.

What Looks Good
The pnpm.overrides mechanism is the correct approach for patching transitive deps without upstream fixes
ajv@^8, mdast-util-to-hast, jquery@^3, and serialize-javascript overrides look correct
Test assertion modernization (toBeCalledWith → toHaveBeenCalledWith) is technically correct (the deprecated forms still work but the non-deprecated form is preferred)
KeycloakSelect.tsx fix removing invalid <> empty generic syntax is a genuine bug fix
PolicyDetails.tsx and EditUser.tsx type cast corrections (as Promise<...>) are correct

Recommendations

Fix the lodash override — it should be "lodash": "^4.17.21" (or whatever the latest 4.17.x is that has the fix), not ^4.18.1
Clarify the missing overrides — either add brace-expansion ^1, brace-expansion ^2, and ajv@^6 if needed, or update the description
Split the PR — keep only pnpm.overrides + lockfile changes in this PR; move source code changes (default removals, context refactor, formatting) to a separate PR for proper review
Audit callers of ConfirmDialog before merging the open default removal — it's the highest regression risk

@abstractj
abstractj commented Apr 24, 2026 •
Copy link
Copy Markdown
Contributor Author

@ssilvert the changes here were to fix the issues with eslint, if they don't make sense. May I ask you to please take over and submit a new one if you would like?

Also I don't care what Claude has to say. I'm more interested on what you think ;)

@edewit
edewit commented Jun 1, 2026
Copy link
Copy Markdown
Contributor

claude is wrong there is lodash 4.18.1

@edewit edewit left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8000

I wouldn't create overrides for all of these:
ajv ^6 => @eslint/eslintrc ^3.3.5 (depends on ajv: ^6.14.0). Bump eslint to latest 9.x. resolves ajv@6.12.6 → 6.14.x

ajv@^8: ^8.18.0 => vite-plugin-dts@4.5.4 allows @microsoft/api-extractor: ^7.50.1
vite-plugin-dts 7.58.x) uses @rushstack/node-core-library with ajv: ~8.18.0. Bump vite-plugin-dts

lodash ^4.18.1 => @patternfly/react-table@5.4.16 and eslint-plugin-lodash use ^4.17.21 pnpm update lodash can land 4.17.23 (CVE fix) without override. api-extractor’s ~4.17.15 also allows 4.17.23 upgrading api-extractor removes lodash from that chain.

mdast-util-to-ha => Chain is @uiw/react-textarea-code-editor → rehype → … → mdast-util-to-hast. hast-util-to-html ^13.2.1 allows ^13.0.0; lockfile has 13.2.0. pnpm update mdast-util-to-hast (or bump the rehype stack) should reach 13.2.1 without override.

@edewit
edewit commented Jun 1, 2026 •
Copy link
Copy Markdown
Contributor

created alternative that does the same, but with less changes #49544

@ssilvert
ssilvert commented Jun 1, 2026
Copy link
Copy Markdown
Contributor

Closed in favor of #49544

@ssilvert ssilvert closed this Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

0