Unverified Commit 01962857 authored by Sebastian "Sebbie" Silbermann's avatar Sebastian "Sebbie" Silbermann Committed by GitHub

Improve performance of validating MPA form submissions (#96013)

https://github.com/vercel/next.js/security/advisories/GHSA-m99w-x7hq-7vfj
parent 669426f4
...@@ -1477,6 +1477,7 @@ function areAllActionIdsValid( ...@@ -1477,6 +1477,7 @@ function areAllActionIdsValid(
mpaFormData: FormData, mpaFormData: FormData,
serverModuleMap: ServerModuleMap serverModuleMap: ServerModuleMap
): boolean { ): boolean {
let seenActionRefs = 0
let hasAtLeastOneAction = false let hasAtLeastOneAction = false
// Before we attempt to decode the payload for a possible MPA action, assert that all // Before we attempt to decode the payload for a possible MPA action, assert that all
// action IDs are valid IDs. If not we should disregard the payload // action IDs are valid IDs. If not we should disregard the payload
...@@ -1494,6 +1495,13 @@ function areAllActionIdsValid( ...@@ -1494,6 +1495,13 @@ function areAllActionIdsValid(
hasAtLeastOneAction = true hasAtLeastOneAction = true
} else if (key.startsWith($ACTION_REF_)) { } else if (key.startsWith($ACTION_REF_)) {
if (++seenActionRefs > 2) {
// We only expect to see at most 2 $ACTION_REF_ fields in the form data:
// one from <form action="..." method="post">
// and one from <input action="..." type="submit">
return false
}
// Bound args case // Bound args case
const actionDescriptorField = const actionDescriptorField =
$ACTION_ + key.slice($ACTION_REF_.length) + ':0' $ACTION_ + key.slice($ACTION_REF_.length) + ':0'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment