Skip to content

Security: Arbitrary File Write via Unsanitized User Input#2181

Open
tomaioo wants to merge 1 commit into
cedarjs:mainfrom
tomaioo:fix/security/arbitrary-file-write-via-unsanitized-use
Open

Security: Arbitrary File Write via Unsanitized User Input#2181
tomaioo wants to merge 1 commit into
cedarjs:mainfrom
tomaioo:fix/security/arbitrary-file-write-via-unsanitized-use

Conversation

@tomaioo

@tomaioo tomaioo commented Jul 23, 2026

Copy link
Copy Markdown

Summary

Security: Arbitrary File Write via Unsanitized User Input

Problem

Severity: High | File: __fixtures__/rsc-caching/web/src/components/ServerDelayForm/actions.ts:L6

The formAction server action writes user-provided form data directly to a JSON file. The delay value from formData.get('delay') is not sanitized or validated before being interpolated into the JSON string. An attacker could submit a malicious payload containing closing braces and arbitrary JSON (or even JavaScript/JSON injection if the file is parsed unsafely elsewhere), leading to file corruption or potential exploitation if this file is later consumed by a vulnerable parser.

Solution

Sanitize and validate the input delay value before writing it to the file. Ensure it is parsed as a number and use JSON.stringify to safely construct the JSON object instead of string interpolation.

Changes

  • __fixtures__/rsc-caching/web/src/components/ServerDelayForm/actions.ts (modified)

The `formAction` server action writes user-provided form data directly to a JSON file. The `delay` value from `formData.get('delay')` is not sanitized or validated before being interpolated into the JSON string. An attacker could submit a malicious payload containing closing braces and arbitrary JSON (or even JavaScript/JSON injection if the file is parsed unsafely elsewhere), leading to file corruption or potential exploitation if this file is later consumed by a vulnerable parser.

Signed-off-by: tomaioo <203048277+tomaioo@users.noreply.github.com>
@netlify

netlify Bot commented Jul 23, 2026

Copy link
Copy Markdown

👷 Deploy request for cedarjs pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 25578b4

@greptile-apps

greptile-apps Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR makes the RSC caching fixture serialize its delay setting safely.

  • Coerces the submitted delay field with Number().
  • Replaces raw JSON interpolation with JSON.stringify().
  • Logs the coerced value rather than the original form value.
  • Does not alter the project architecture described in docs/implementation-docs/2026-03-26-cedarjs-project-overview.md.

Confidence Score: 4/5

The invalid-duration handling should be fixed before merging because crafted values can silently disable or distort the fixture's configured delay.

The serialization change closes raw JSON injection, but the server action does not reject non-finite, negative, or oversized durations before persisting them for use by setTimeout.

fixtures/rsc-caching/web/src/components/ServerDelayForm/actions.ts

Important Files Changed

Filename Overview
fixtures/rsc-caching/web/src/components/ServerDelayForm/actions.ts Safely serializes the settings object, but numeric coercion still admits unsupported durations that produce incorrect delay behavior.

Reviews (1): Last reviewed commit: "fix(security): arbitrary file write via ..." | Re-trigger Greptile


export async function formAction(formData: FormData) {
console.log(formData.get('delay'))
const delay = Number(formData.get('delay'))

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.

P1 Invalid durations remain accepted

When a crafted submission contains a non-finite, negative, or excessively large delay, Number() accepts it without range validation and the stored value becomes null or an unsupported timer duration, causing the requested delay to become zero or execute almost immediately.

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.

1 participant