fix: prevent command injection in WebAuthn/Push test LocalServers - #4252
Merged
Conversation
…Servers The LocalServer test utilities built shell command strings by interpolating the request-body `deviceId` (and, for push, notification fields) and ran them via child_process.exec, which spawns /bin/sh. A crafted deviceId such as "booted; <cmd>" sent to the localhost endpoints achieved arbitrary shell command execution as the developer's user. Fixes both test servers (AuthWebAuthnApp and PushNotificationHostApp): - Replace exec() with execFile(), passing arguments as an array so no shell is invoked and user input is never interpreted as shell syntax. - /enroll: split the '&&'-chained command into two sequential execFile calls. - /notifications: write the APNS JSON payload to the process stdin instead of piping it through 'echo | ...' in a shell. - Add UUID/"booted" validation on deviceId as defense-in-depth. Impact is limited to developer workstations manually running these localhost-only test servers; no shipped SDK code is affected.
thisisabhash
approved these changes
Jul 16, 2026
This was referenced Aug 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
The Node test utilities under
AmplifyPlugins/.../LocalServer/index.mjs(used only to drive the iOS Simulator during WebAuthn and Push Notification UI tests) built shell command strings by interpolating request-body input and executed them withchild_process.exec, which spawns/bin/sh.For example:
A
deviceIdsuch asbooted; <command>posted to the localhost endpoints would therefore run arbitrary shell commands. The push server was additionally affected on/notifications, where the notification payload was piped throughecho '<json>' | xcrun simctl push ...in a shell.Impact is limited to developer machines that manually start these localhost-only test servers; no shipped SDK code is affected. Fixing it removes the footgun and keeps the test tooling safe.
Changes
Both test servers (
AuthWebAuthnAppandPushNotificationHostApp):exec()withexecFile(), passing arguments as an array so no shell is invoked and inputs are never interpreted as shell syntax./enroll: split the&&-chained command into two sequentialexecFilecalls./notifications: write the APNS JSON payload to the child process's stdin instead of piping it throughecho | ....deviceIdvalidation (UUID orbooted) as defense-in-depth.No dependency or
package.jsonchanges —execFileis part of corenode:child_process.Verification
Ran both servers locally against a stubbed
xcrunthat records its argv/stdin:deviceId(booted/ UUID): commands run with the expected argument vector.deviceIdcontaining shell metacharacters: rejected with400, no command executed.titleon/notifications: delivered verbatim as JSON via stdin, not executed.A payload designed to
touch /tmp/pwnedproduced no file in any case.