You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Security question: Why are data: URIs and file: URIs treated differently in your security policy? #53815
I noticed this bug report and asked @RafaelGSS why data: URIs are treated differently from file: URIs in the node.js security policy, as attackers can simply write to a file and then import it to achieve the same effect.
Rafael responded with the following, asking me to file an issue in this bug tracker instead of elaborating on X:
This vulnerability exposes a vulnerability according to Node.js threat model. I can expand more on that if you raise an issue.
But I certainly won't elaborate on a X thread :)
How often does it reproduce? Is there a required condition?
No response
What is the expected behavior? Why is that the expected behavior?
No response
What do you see instead?
N/A. I was requested by @RafaelGSS to use this issue reporting form.
changed the title [-]Security question: why are data: URIs and file: URIs treated differently in your security policy?[/-][+]Security question: Why are data: URIs and file: URIs treated differently in your security policy?[/+]on Jul 11, 2024
The report was disclosed limited, so that's explains why you can only read the summary:
A security flaw in Node.js allows a bypass of network import restrictions.
By embedding non-network imports in data URLs, an attacker can execute arbitrary code, compromising system security.
Verified on various platforms, the vulnerability is mitigated by forbidding data URLs in network imports.
Exploiting this flaw can violate network import security, posing a risk to developers and servers.
I will try to adjust it either way.
I believe your question is unrelated to the vulnerability itself. I will provide more details about the report, but I might not be the best person to explain our resolvers.
Imagine you have an HTTP server with two routes:
/indirect -> returns a
import childProcess from 'data:text/javascript,export { default } from "node:child_process"'
import http from 'data:text/javascript,export { default } from "node:http"'
console.log('BYPASSED')
const data = childProcess.execSync('cat /etc/passwd')
/direct -> returns a import fs from 'node:fs/promises'
While the /direct route produces the expected result:
$ node --experimental-network-imports --import 'http://127.0.0.1:9999/direct.mjs' --eval ''Error [ERR_NETWORK_IMPORT_DISALLOWED]: import of 'node:fs/promises' by http://localhost:9999/direct.mjs is not supported: only relative and absolute specifiers are supported.
the /indirect is a bypass of this feature's expectations
Your response does not acknowledge my question about file: URIs.
I am repeating my question: Why are data: URIs treated differently from file: URIs? Attackers can simply write to a file and then import it to achieve the same effect.
Activity
[-]Security question: why are data: URIs and file: URIs treated differently in your security policy?[/-][+]Security question: Why are data: URIs and file: URIs treated differently in your security policy?[/+]avivkeller commentedon Jul 11, 2024
@nodejs/security-wg
CC @RafaelGSS
RafaelGSS commentedon Jul 12, 2024
So I couple of things first:
I will try to adjust it either way.
Imagine you have an HTTP server with two routes:
/indirect-> returns a/direct-> returns aimport fs from 'node:fs/promises'While the
/directroute produces the expected result:the
/indirectis a bypass of this feature's expectationsRafaelGSS commentedon Jul 12, 2024
Also note, that we are discussing removing this feature entirely #53822.
eligrey commentedon Jul 12, 2024
Your response does not acknowledge my question about file: URIs.
I am repeating my question: Why are data: URIs treated differently from file: URIs? Attackers can simply write to a file and then import it to achieve the same effect.