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

Function prototype set to undefined inconsistently too late #2598

Closed
Tracked by #1891
leotm opened this issue Oct 21, 2024 · 0 comments · Fixed by #2624
Closed
Tracked by #1891

Function prototype set to undefined inconsistently too late #2598

leotm opened this issue Oct 21, 2024 · 0 comments · Fixed by #2624
Assignees
Labels
bug Something isn't working

Comments

@leotm
Copy link
Contributor

leotm commented Oct 21, 2024

Describe the bug

On Hermes we never reach (in whitelistIntrinsics)

if (typeof obj === 'function' && prop === 'prototype') {
obj.prototype = undefined;

but reach here first instead

const completePrototypes = () => {
for (const [name, intrinsic] of entries(intrinsics)) {
if (!isObject(intrinsic)) {
// eslint-disable-next-line no-continue
continue;
}
if (!objectHasOwnProperty(intrinsic, 'prototype')) {
// eslint-disable-next-line no-continue
continue;
}
const permit = permitted[name];
if (typeof permit !== 'object') {
throw TypeError(`Expected permit object at whitelist.${name}`);
}
const namePrototype = permit.prototype;
if (!namePrototype) {
throw TypeError(`${name}.prototype property not whitelisted`);

order of events and conditions

  • intrinsics.js > completePrototypes
    • isObject(intrinsic)
    • objectHasOwnProperty(intrinsic, 'prototype')
    • typeof permit === 'object'
    • !permit.prototype
      • throw TypeError(`${name}.prototype property not whitelisted`);
  • permit-intrinsics.js > whitelistIntrinsics

Steps to reproduce

Expected behavior

The prototype to be set to undefined earlier
so we continue which skips throwing the TypeError

Platform environment

  • macOS Sequoia 15.0.1
  • Node v20.12.2
  • Hermes v0.12.0 (lockdown), v0.13.0 (harden)
  • @endo/base64@1.0.8-10-gb3a31b155

Additional context

Note: on Static Hermes this is a non-issue, since both prototype bugs are fixed

Screenshots

lockdown prototype property not whitelisted
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants