Skip to content

PD-6118 semgrep angular vulnerabilities - #2906

Open
cryptalith wants to merge 4 commits into
mainfrom
lmendoa/PD-6118-semgrep-angular-vulnerabilities
Open

PD-6118 semgrep angular vulnerabilities#2906
cryptalith wants to merge 4 commits into
mainfrom
lmendoa/PD-6118-semgrep-angular-vulnerabilities

Conversation

@cryptalith

Copy link
Copy Markdown
Member

No description provided.

Semgrep reported 440 High/Reachable/Direct supply-chain findings against
orcid-angular. They are one row per usage site and collapse to three
CVEs, all in Angular 20.1.6:

  CVE-2025-66035  @angular/common    XSRF token leak     (fixed 20.3.14)
  CVE-2026-22610  @angular/compiler  SVG script href XSS (fixed 20.3.16)
  CVE-2026-54267  @angular/core      hydration clobbering(fixed 20.3.25)

Move the framework to 20.3.27, CDK and Material to 20.2.14, and the CLI
toolchain to 20.3.33. Staying on v20 means no migration. This also picks
up the i18n XSS advisories, which are not in the Semgrep export but
matter more here than the SVG one, since the app ships ten locales and
has no attr.href bindings anywhere. Audit count drops from 79 to 44 with
no runtime package left affected; the rest is build tooling.

Also drop provideClientHydration() from orcid-ui-elements. No project in
angular.json builds with SSR or prerendering, so it restores nothing and
only arms the ng-state lookup CVE-2026-54267 abuses — a bad trade in a
bundle that embeds into third-party pages.
CVE-2025-66035 describes HttpClient treating protocol-relative URLs as
same-origin and attaching the XSRF header. Our fallback interceptor had
the same defect independently, so upgrading Angular does not fix it:

    const isRelativeRequest = req.url.startsWith('/')

'//evil.com/steal' satisfies that test, so the request was classified as
backend, matched no auth host, fell through to XSRF-TOKEN and was sent
with the token attached and withCredentials set.

toAbsoluteUrl() already resolved '//' correctly for the host comparisons,
which is what made this easy to miss — the host checks were right and the
relative check short-circuited past them.

This is live traffic rather than a corner case: API_WEB and BASE_URL are
themselves protocol-relative, so '//host/path' is the normal shape of a
backend call here. Exclude the '//' prefix from the relative test only;
host comparison still accepts a protocol-relative URL that genuinely
points at the API. Both directions are covered by tests — a foreign host
gets nothing, the API host still gets its token.
src/test.ts was configured as the karma main but contained only the
zone.js import and initTestEnvironment — the require.context that pulls
in spec files was missing. With a main set, the builder loads only that
entry, so ng test ran 1 test while 334 spec files sat unexecuted. The
suite has effectively been a no-op in CI, which is why a live XSRF flaw
survived in a file that ships with tests.

Declare zone.js/testing alongside the existing polyfills and drop main,
which lets the builder discover specs from tsconfig.spec.json. Delete
test.ts, now unreachable, and drop it from the spec tsconfig files list.
Turning spec discovery back on surfaced six component specs that had
never run. They fail identically on 20.1.6, so none of this is fallout
from the upgrade — they simply rotted unobserved.

Most were missing TestBed imports for what their templates actually use:
MatFormField/MatInput for mat-form-field and the errorStateMatcher
binding, MatCard/MatCheckbox for the interstitial, ReactiveFormsModule
for [formGroup], and CUSTOM_ELEMENTS_SCHEMA where a template renders a
sibling app-* component. Real modules rather than NO_ERRORS_SCHEMA, so
the specs keep catching template errors.

Two specs stubbed FormBuilder with object literals that only looked like
form controls. They passed only because ReactiveFormsModule was absent
and the bindings were never evaluated; with the directives present they
have to be real, so use the actual FormBuilder. ShareEmailsDomains also
needed a record carrying emailDomains, since the component builds its
form inside a filtered subscription and an empty record left formGroup
bound to undefined.

Full suite: 686 passing, 0 failures.
@amontenegro

Copy link
Copy Markdown
Member

@cryptalith cryptalith changed the title Lmendoa/pd 6118 semgrep angular vulnerabilities PD-6118 semgrep angular vulnerabilities Aug 20, 2026
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.

2 participants