Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ses): fix #2598 with cauterizeProperty reuse #2624

Merged
merged 7 commits into from
Nov 13, 2024

Conversation

erights
Copy link
Contributor

@erights erights commented Nov 4, 2024

Closes: #2598
Refs: #2563 #2334 #1221

Description

#1221 was supposed to make ses tolerate undeletable func.prototype properties that should be absent, so long as they could be set to undefined instead, making them harmless. This tolerance came with a warning to flag the remaining non-conformance.

However #2598 explains why #1221 sometimes fails to do this. #1221 did come with a test, but it fell into the case where #1221 works, which is a non-toplevel function.

#2563 (and #2334 ?) fell into the trap explained by #2598 and untested by #1221, which is an undeletable func.prototype on a top-level instrinsic. As a result, #2563 currently contains a workaround for #2598 which this PR would make unnecessary.

This PR fixes the problem by factoring out the func.prototype-tolerant property deletion into a separate cauterizeProperty function which it calls from both places. This PR also adds the test that was missing from #1221 , having first checked that the test detects #2598 when run without the rest of this PR.

If this PR gets merged before #2563, then #2563's workaround for #2598 can first be removed before it is merged.

  • TODO should pass a genuine reporter in to all calls to cauterizeProperty. @kriskowal , please advise how intrinsics.js should arrange to do so.

Security Considerations

Allowing a func.prototype property that really shouldn't be there seems safe, so long as it is safely set to undefined first, which this PR does, and then checks that it has done so.

Scaling Considerations

none

Documentation Considerations

generally, this would be one less thing to worry about, and thus one less thing that needs to be documented for most users.

Testing Considerations

Adds the test that was missing from #1221 that let #2598 go unnoticed until #2563

Compatibility Considerations

Should be none.

Upgrade Considerations

Should be none.

@erights erights self-assigned this Nov 4, 2024
@erights erights marked this pull request as ready for review November 4, 2024 22:26
@erights erights force-pushed the markm-2598-set-func-proto-undefined branch from 578772d to fd0660f Compare November 4, 2024 22:30
packages/ses/src/cauterize-property.js Outdated Show resolved Hide resolved
packages/ses/src/cauterize-property.js Outdated Show resolved Hide resolved
@erights erights force-pushed the markm-2598-set-func-proto-undefined branch from 3477f75 to 7beacaa Compare November 5, 2024 19:00
@erights erights force-pushed the markm-2598-set-func-proto-undefined branch from 7beacaa to e74d031 Compare November 10, 2024 20:12
@erights erights force-pushed the markm-2598-set-func-proto-undefined branch from fac3fae to 6b9c271 Compare November 12, 2024 22:29
Copy link
Member

@kriskowal kriskowal left a comment

Choose a reason for hiding this comment

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

I have recommended options for threading the reporter, and any of those options are fine by me: we can either thread the reporter through all callers of getGlobalIntrinsics, or construct the intrinsics collector from the reporter available in lockdown and inject that instead.

packages/ses/src/permits-intrinsics.js Outdated Show resolved Hide resolved
packages/ses/src/intrinsics.js Show resolved Hide resolved
packages/ses/src/cauterize-property.js Show resolved Hide resolved
@erights erights enabled auto-merge (squash) November 13, 2024 19:46
@erights erights merged commit d13bf9c into master Nov 13, 2024
15 checks passed
@erights erights deleted the markm-2598-set-func-proto-undefined branch November 13, 2024 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Function prototype set to undefined inconsistently too late
6 participants