Fix: Default resolveSourceMapAnnotations to false to prevent arbitrary file read (#4322) - #4331
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
2897ce8 to
67d8f84
Compare
67d8f84 to
bfd4d3e
Compare
|
Hi @lauraharker, The Google CLA is signed and verified. I've updated the PR with:
Please take a look when you have a chance. Thanks! |
|
Hi Kunal - I think we're somewhat concerned about flipping the default here breaking existing workflows. What do you think about restricting file reads to some heuristically "safe" set of directories? |
|
Hi @lauraharker , Appreciate the feedback — agreed, flipping the default isn't really the fix. It just hides the problem, since anyone who turns For the "safe directories" idea, I want to keep it simple: a One thing worth calling out on scope — Plan:
Separately, something to think about later: |
Summary
Fixes #4322.
Changes
CompilerOptions.resolveSourceMapAnnotationsto default tofalseinstead oftrue.Rationale
When
resolveSourceMapAnnotationsistrueby default, compiling untrusted JS containing a//# sourceMappingURL=comment causesSourceMapResolver.extractSourceMapto resolve local filesystem paths automatically, creating an arbitrary file read vulnerability for untrusted inputs.Flipping this default ensures
closure-compileris secure-by-default when handling untrusted JS inputs, following the mitigation pattern used for CVE-2026-49356 (@babel/core). Callers compiling trusted code can explicitly enable resolution viaoptions.setResolveSourceMapAnnotations(true).Verification
testResolveSourceMapAnnotationsDefaultsToFalseinCompilerOptionsTest.java.bazel test //:test/com/google/javascript/jscomp/CompilerOptionsTest(PASSED).cc @lauraharker