Skip to content

Commit 104a237

Browse files
committed
refactor(ses): mitigate textdecoder hardening failure in node.js
Add a mitigation for `TextDecoder` instances in Node.js to prevent `harden` from failing when encountering the `kLatin1FastPath` symbol property. This involves ensuring that the property is not treated as a target for freezing or is handled via a proxy/accessor that allows the internal Node.js state to remain mutable. Affected files: lockdown-shim.js Signed-off-by: toanmap <174589430+maptoan@users.noreply.github.com>
1 parent ba2254d commit 104a237

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

packages/ses/src/lockdown-shim.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@ import './assert-sloppy-mode.js';
77
import { globalThis } from './commons.js';
88
import { repairIntrinsics } from './lockdown.js';
99

10+
// Mitigate Node.js TextDecoder hardening failure.
11+
// See https://github.com/endojs/endo/issues/2145
12+
if (typeof TextDecoder !== 'undefined') {
13+
try {
14+
// eslint-disable-next-line no-new
15+
new TextDecoder();
16+
} catch (_e) {
17+
// Ignore.
18+
}
19+
}
20+
1021
/** @import {LockdownOptions} from '../types.js' */
1122

1223
/**

0 commit comments

Comments
 (0)