Skip to content

fix: resolve fast-xml-parser HIGH/CRITICAL vulnerabilities - #3477

Merged
Simone319 merged 24 commits into
mainfrom
fix/fast-xml-parser-vulnerabilities
Jun 30, 2026
Merged

fix: resolve fast-xml-parser HIGH/CRITICAL vulnerabilities#3477
Simone319 merged 24 commits into
mainfrom
fix/fast-xml-parser-vulnerabilities

Conversation

@Simone319

@Simone319 Simone319 commented May 5, 2026

Copy link
Copy Markdown
Contributor

Description

This PR addresses fast-xml-parser security vulnerabilities and a set of related dependency/bundling hygiene fixes, plus stabilizes the conversation and generation e2e tests that gate this change.

1. Security / dependency resolutions (root package.json)

Added / updated resolutions to force safe versions tree-wide:

  • **/fast-xml-parser: ~5.7.2, **/fast-xml-builder: >=1.1.7 (replaces the previous narrow **/aws-amplify/**/fast-xml-parser: ~5.5.12 resolution)
  • @aws-sdk/core: ^3.974.23 (replaces the previous @aws-sdk/core/@aws-sdk/xml-builder pin; eliminates stale xml-builder carriers that pulled in fast-xml-parser)
  • @opentelemetry/core: >=2.8.0
  • uuid: ^11.1.1 (pinned to 11.x — NOT >=, which would resolve to ESM-only 14.x)
  • Additional advisory/hygiene bumps: axios: ^1.16.1, tmp: ^0.2.6, basic-ftp: >=5.3.1, @xmldom/xmldom: >=0.9.10, fast-uri: >=3.1.2, flatted: >=3.4.2, @aws-amplify/plugin-types: 1.12.1

2. AWS SDK upgrades in construct packages

amplify-graphql-api-construct and amplify-data-construct:

  • @aws-sdk/* client packages (client-bedrock-runtime, client-sso, client-sso-oidc, client-sts, token-providers) bumped to ^3.1074.0; supporting middleware/util/credential-provider packages bumped to the ^3.972/3.973 release line; @aws-sdk/core: ^3.974.23.
  • @aws-amplify/ai-constructs: ^1.6.1 → ^1.6.2; uuid: ^9.0.1 → ^11.1.1.
  • Removed fast-xml-parser, fast-xml-builder, path-expression-matcher, and strnum from dependencies, bundledDependencies, and the root nohoist list (no longer pulled in after the SDK upgrade).
  • Added @aws-sdk/middleware-sdk-s3, @aws-sdk/middleware-websocket, @aws-sdk/signature-v4-multi-region, @aws-sdk/util-arn-parser, and @aws-sdk/util-format-url to dependencies + bundledDependencies (and root nohoist) so the published bundle stays complete with the upgraded SDK.
  • Regenerated dependency_licenses.txt, both .jsii files, and yarn.lock.

3. AWS SDK upgrades in test / tooling packages

  • amplify-graphql-api-construct-tests, amplify-e2e-tests, amplify-graphql-model-transformer, amplify-graphql-schema-generator, and graphql-transformers-e2e-tests: @aws-sdk/client-* (and @aws-sdk/types) bumped to ^3.973.0.
  • scripts/package.json: axios → ^1.16.1 plus added resolutions (fast-xml-parser >=5.5.6, minimatch >=9.0.6, axios >=1.16.1); scripts/yarn.lock regenerated.
  • graphql-transformers-e2e-tests jsonServer fixtures: added resolutions (minimatch 3.1.5) and lodash >=4.17.23; regenerated both jsonServer yarn.lock files.

4. Conversation e2e test fix

  • Added optional type: String to AmplifyAIToolUseBlockInput in three places: the conversation test schema fixture (schema-conversation.graphql), the transformer test schema fixture (conversation-schema-types.graphql), and the generated API.ts. Root cause: a newer bundled @aws-sdk/client-bedrock-runtime (via @aws-amplify/ai-constructs) added a type field to ToolUseBlock; the handler spreads the whole SDK object into the GraphQL mutation, so AppSync rejected the unknown field. The schema addition is backward-compatible (optional).
  • Updated conversation test aiModel to global.anthropic.claude-haiku-4-5-20251001-v1:0.
  • Hardened the subscription loops: added deadline + max-event fail-fast guards and surfaced errors[] stream parts immediately; switched the response-text assertion from accumulated p (now optional stream padding) to accumulated contentBlockText.

5. Generation e2e test fix

  • Updated generation test aiModel to amazon.nova-lite-v1:0 and added fail-fast guards (assert no GraphQL errors, assert recipe is non-null).

6. Lint fix

  • amplify-e2e-core/src/init/initProjectHelper.ts: wrapped an over-width console.log to satisfy prettier.

Testing

  • pr-workflow: green (lint / prettier-check passing on latest head).
  • Conversation and generation e2e suites pass with the updated model ids and guards; remaining e2e failures are known-environmental only (cleanup S3 timeouts, IAM/AppSync quota in the shared test account, transient module-resolution flakes).

…ties

Upgrades AWS SDK client packages and adds a resolution to eliminate
vulnerable fast-xml-parser versions (4.4.1, 5.2.5, 5.5.2) from the
dependency tree.

Changes:
- Broadened fast-xml-parser resolution to force all instances to ~5.5.12
- Updated @aws-sdk/core, @aws-sdk/xml-builder and related packages in
  amplify-data-construct and amplify-graphql-api-construct
- Upgraded direct fast-xml-parser dep from 5.5.2 to ~5.5.12 in constructs
- Upgraded AWS SDK clients in test packages to ^3.973.0

After these changes, yarn.lock contains only fast-xml-parser@5.5.12
(safe, >= 5.5.6) with no vulnerable versions remaining.
@Simone319
Simone319 requested a review from a team as a code owner May 5, 2026 16:22
Remove stale lockfile entries for @aws-sdk packages in the 3.775.x and
3.810.x version families that declared fast-xml-parser 4.4.1. These came
from aws-appsync@4.1.10 (via @aws-sdk/client-s3@^3.25.0 resolved to
3.779.0) and @aws-cdk/toolkit-lib@1.16.0 (via @aws-sdk/client-*@^3
resolved to 3.810.0).

After removal, yarn install re-resolved these ranges to the latest
compatible versions which use @aws-sdk/core >= 3.974.8 (no fast-xml-parser
dependency).

Remaining: @aws-sdk/core@3.622.0 from @aws-amplify/ai-constructs@1.6.1
still declares fast-xml-parser 4.4.1, but the resolution forces it to
5.5.12. This will be addressed separately.
@RestingState

Copy link
Copy Markdown

Got this warning as well. It would be nice if that fix is merged ASAP

Main yarn.lock:
- fast-xml-parser ~5.5.12 → ~5.7.2 (resolves to 5.7.3)
- fast-xml-builder 1.1.4 → 1.2.0
- axios 1.15.0 → 1.16.1
- @xmldom/xmldom 0.9.9 → 0.9.10
- basic-ftp 5.2.2 → 6.0.1
- picomatch 2.3.1/4.0.3 → 2.3.2/4.0.4
- flatted 3.3.3 → 3.4.2
- fast-uri 3.0.6 → 3.1.2
- tmp 0.2.5 → 0.2.7
- @aws-amplify/ai-constructs 1.6.1 → 1.6.2

scripts/yarn.lock:
- axios 1.12.0 → 1.16.1
- minimatch 9.0.5 → 10.2.5
- fast-xml-parser 4.4.1 → 5.8.0

jsonServer/yarn.lock:
- minimatch 3.1.2 → 3.1.5

jsonServer/src-server/yarn.lock:
- lodash 4.17.21 → 4.18.1
@Simone319
Simone319 requested a review from a team as a code owner June 2, 2026 12:34
Simone319 and others added 13 commits June 26, 2026 10:15
…y advisories

- @aws-sdk/xml-builder ^3.972.0 -> ^3.972.31 in both constructs (root
  resolution @aws-sdk/core/@aws-sdk/xml-builder -> ^3.972.31). 3.972.31 is
  the first release containing aws-sdk-js-v3#7863, which replaces
  fast-xml-parser with an internal XML parser.
- @opentelemetry/core pinned to >=2.8.0 via root resolutions
  (GHSA-8988-4f7v-96qf); resolves to 2.8.0.
- uuid pinned to ^11.1.1 via root resolutions + both constructs
  (GHSA-w5hq-g745-h8pq); resolves to 11.1.1, the patched legacy-11 release.
  Avoids uuid 14.x which is ESM-first.
…m constructs

Bumps @aws-sdk client packages (client-bedrock-runtime, client-sso,
client-sso-oidc, client-sts, token-providers) to ^3.1074.0 and pins
@aws-sdk/core to ^3.974.23 (the 3.1074 release line). Adds a root
resolution forcing all @aws-sdk/core to 3.974.23, which depends on
@aws-sdk/xml-builder@^3.972.31 — the version that removed
fast-xml-parser. This collapses the previously stale core/xml-builder
3.972.15/22/26 resolutions (which still pulled fast-xml-parser) onto
the fast-xml-parser-free 3.972.31.

Removes the now-orphaned fast-xml-parser dependency chain
(fast-xml-parser, fast-xml-builder, @nodable/entities,
path-expression-matcher, strnum, xml-naming) from both constructs'
dependencies + bundledDependencies and the root nohoist config, since
xml-builder@3.972.31 no longer pulls them. The **/fast-xml-parser and
**/fast-xml-builder safety resolutions are retained to keep legacy
@aws-sdk v3 consumers (client-s3@3.6.1, client-sts@3.186.0) on the
patched fast-xml-parser@5.7.3.
…error/null guards)

Two Gen2-cdk e2e suites (generation, conversation) were failing for
reasons unrelated to product code. This change fixes the test fixtures
and adds fail-fast hygiene guards. Test-side only; no product behavior
changes.

Model ids
  The fixtures invoked anthropic.claude-3-haiku-20240307-v1:0, a legacy
  Bedrock model that has been auto-revoked in the e2e account; invoking
  it returned ResourceNotFoundException, AppSync resolved null, and the
  tests crashed on a null-deref.

  - generation: the @generation transformer's AppSync->Bedrock IAM role
    grants bedrock:InvokeModel only on the foundation-model ARN, so a
    cross-region inference profile fails with AccessDenied. The
    generation fixture is switched to the active on-demand foundation
    model mistral.mistral-large-2407-v1:0, which the e2e account can
    invoke under the existing IAM and which satisfies the basic
    text/scalar assertions.

  - conversation: routes via @aws-amplify/ai-constructs, which handles
    inference-profile IAM, so the conversation fixture uses the active
    inference profile us.anthropic.claude-haiku-4-5-20251001-v1:0.

Fail-fast guards
  generation.test.ts: assert the GraphQL response has no errors and that
  the generated recipe is not null before dereferencing, so a
  Bedrock/GraphQL error is printed instead of a TypeError.

  conversation.test.ts: replace the ineffective toBeDefined() check on
  the stream part with not.toBeNull(), guard the .length read when the
  part is null, and add a max-iteration / overall-timeout guard inside
  the subscription for-await loop so a non-streaming assistant fails
  fast with a descriptive message instead of cascading into the jest
  timeout.

---
Prompt: Split the mixed e2e/CI branch into a clean draft PR off main
containing only the generation/conversation e2e test fixes: switch the
dead legacy claude-3-haiku model id to a working model (generation ->
mistral plain on-demand FM, conversation -> working inference profile)
and add the error/null fail-fast guards. tsc the construct-tests
package and commit (no --no-verify).

(cherry picked from commit d3e8617)
…ol-use/structured output)

(cherry picked from commit 3a02ac7)
…` assertions for haiku-4-5

The conversation happy-path e2e asserted every streamed
ConversationMessageStreamPart had a non-null `p` and aggregated `p`
into a non-empty string. That premise is wrong: `p` is optional stream
padding, not response text. The ai-constructs Bedrock converse adapter
only sets `p` when the underlying Bedrock contentBlockDelta carries a
string padding field, and never sets it on control frames
(contentBlockStop, the final stopReason chunk). claude-haiku-4-5 emits
no `p` padding at all, so the subscription delivers `p: null` on every
part, failing `expect(streamPart.p).not.toBeNull()` on the first frame
and cascading the other cases into timeouts.

Verified directly against
us.anthropic.claude-haiku-4-5-20251001-v1:0 via Bedrock ConverseStream:
the model returns the full pirate response (stopReason end_turn) with
text delivered through contentBlockDelta/contentBlockText and no `p`
padding on any frame. The assistant text is mapped correctly, so this
is a test-assertion issue, not a resolver bug.

Drop the contradictory not-null assertion, keep the `p` length check
when padding is present, and assert the aggregate streamed
contentBlockText is non-empty so the test still meaningfully verifies a
real streaming response was received.

---
Prompt: Gen2 PR #3500 conversation e2e shard failed at
conversation.test.ts:136 expect(streamPart.p).not.toBeNull() with model
us.anthropic.claude-haiku-4-5. Determine whether haiku-4-5 returns the
pirate text interleaved with null-p control frames (assertion is wrong,
fix it properly) or whether no assistant text arrives (real resolver
bug, report it, do not loosen the test). Gather evidence from the CI log
and the stream-part type/resolver, then fix or report. Commit to the
branch with a conventional message, no --no-verify, follow
CODING_GUIDELINES.md, and push.

(cherry picked from commit 84331e7)
…ile for conversation haiku-4-5

ai-constructs v1.6.2 only grants correct Bedrock IAM for global.-prefixed model ids;
switch pirateChat @conversation aiModel from us. to global. profile.
…S3/IAM operations

Cherry-picked from 7a697364c (excluding stray .roko notepad file).
Adds ConfiguredRetryStrategy + isNetworkError guards to cleanup-e2e-resources.ts
and TimeoutError/ETIMEDOUT/ECONNRESET handling to retries.ts.
…ckInput (ai-constructs sends SDK ToolUseBlock.type)
@Simone319
Simone319 merged commit c801faa into main Jun 30, 2026
7 of 8 checks passed
@Simone319
Simone319 deleted the fix/fast-xml-parser-vulnerabilities branch June 30, 2026 08:26
Simone319 added a commit that referenced this pull request Jul 2, 2026
…act + direct @smithy) — lands below pre-#3477 baseline with minimal blast radius
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants