Skip to content

fix(adhoc-sweep-fixes): CU-86akdypw4 36 review findings across 19 files - #165

Draft
flamingo[bot] wants to merge 19 commits into
masterfrom
ai-fix/adhoc-sweep-fixes-9a5cd63b-a271a374
Draft

fix(adhoc-sweep-fixes): CU-86akdypw4 36 review findings across 19 files#165
flamingo[bot] wants to merge 19 commits into
masterfrom
ai-fix/adhoc-sweep-fixes-9a5cd63b-a271a374

Conversation

@flamingo

@flamingo flamingo Bot commented Sep 7, 2026

Copy link
Copy Markdown

Closes 36 review findings across 19 files.

Draft — this is a starting point, not a finished change. The fix required judgment, so read it before trusting it.

# Fix confidence Finding Location
1 🟢 97 high Stray trailing 'f' identifier after require() call breaks pkcs7-modified.js loading path pkcs7-modified.js:30
2 🟡 70 medium amt-scanner.js: incorrect min bound off-by-one and dead variable in parseIPv4Range CIDR branch agents/modules_meshcmd/amt-scanner.js:64
3 🟡 60 medium amt-scanner.js scan() uses delete server on a local variable, which has no effect and leaks socket reference agents/modules_meshcmd/amt-scanner.js:97
4 🔴 40 low — review closely amt-scanner.js: server.on('error') handler only logs, never invokes callback — scan hangs on socket error agents/modules_meshcmd/amt-scanner.js:92
5 🟡 70 medium /generate-msh host parameter used to build WebSocket URL without validation, enabling potential SSRF-like agent redirection plugins/openframe.js:62
6 🟡 85 medium db.Get callback in /api/deviceStatus does not check the err parameter plugins/openframe.js:115
7 🟡 80 medium generate-msh host handling truncates protocol but doesn't otherwise sanitize before embedding in generated config plugins/openframe.js:75
8 🟢 95 high amtprovisioningserver.js: socket 'data' handler misuses Buffer.concat return value (data never actually accumulated) amtprovisioningserver.js:41
9 🟢 90 high amtprovisioningserver.js uses non-standard jshint hint block ('/xjslint .../') instead of the conventional directives amtprovisioningserver.js:9
10 🟡 75 medium meshscanner.js obj.start() references undefined domain and req variables when building title2 placeholders meshscanner.js:166
11 🟡 70 medium meshscanner.js swallows all socket bind/setup errors with empty catch blocks, hiding startup failures meshscanner.js:97
12 🟢 95 high Unused/undeclared 'length' global leaks in gcc.js readConferenceCreateResponse/Request rdp/protocol/t125/gcc.js:447
13 🟢 95 high Implicit global 'serverSettings'/'clientSettings' variables in gcc.js rdp/protocol/t125/gcc.js:448
14 🟢 95 high console.info1 is not a standard console method — likely a typo causing a runtime TypeError agents/modules_meshcmd/amt-lme.js:215
15 🟡 65 medium amt-lme.js compares Buffer to string with == instead of comparing strings, name check will always be false agents/modules_meshcmd/amt-lme.js:156
16 🟢 92 high amtInfo() dereferences data[131] without checking it exists, causing a possible crash agents/modules_meshcmd/smbios.js:301
17 🟡 60 medium smbios.js lacks jshint directives and 'use strict' header agents/modules_meshcmd/smbios.js:17
18 🟡 85 medium macos_memUtilization returns undefined instead of the expected promise on the happy path agents/modules_meshcmd/sysinfo.js:197
19 🟡 80 medium child_process stdout accumulation missing for macos_memUtilization stderr stream agents/modules_meshcmd/sysinfo.js:197
20 🟢 92 high Dead/unreachable console.log call after unconditional func() invocation in ResolveName amtscanner.js:153
21 🔴 55 low — review closely rangeinfo.timer in performRangeScan is never cleared, leaking a setTimeout on the outer var-captured rangeinfo amtscanner.js:76
22 🟢 90 high interceptor.js: same min/max inversion bug duplicated in processBrowserDataEx LengthBody mode interceptor.js:197
23 🟡 70 medium interceptor.js: wrong accumulator object referenced in processBrowserDataEx's ChunkedBody branch (obj.amt instead of obj.ws) interceptor.js:206
24 🟢 95 high getPluginConfig has an unreachable synchronous reject after async http.get is already initiated pluginHandler.js:252
25 🔴 20 low — review closely pluginHandler.js downloads and requires third-party plugin JS with no signature or integrity verification pluginHandler.js:250
26 🟢 90 high fs.mkdirSync / fs.closeSync(fs.openSync) calls in recovery-console file-command handler are unguarded and will throw on failure agents/agentrecoverycore.js:256
27 🔴 55 low — review closely AddCommandHandler switch on data.action in agentrecoverycore.js lacks a default case logging unknown actions agents/agentrecoverycore.js:130
28 🟡 75 medium amt-xml.js _PutObjToBodyXml builds XML via raw string concatenation without escaping property values amt/amt-xml.js:102
29 🔴 55 low — review closely ParseWsman swallows all XML parse errors and logs the raw (possibly huge/sensitive) input to console amt/amt-xml.js:50
30 🔴 55 low — review closely rdp/core/layer.js TLS connections disable certificate validation unconditionally (rejectUnauthorized: false) rdp/core/layer.js:153
31 🔴 50 low — review closely rdp/core/layer.js swallows TLS handshake errors from tls.connect callback without checking err before proceeding rdp/core/layer.js:153
32 🔴 30 low — review closely AMT device blocklist check missing before establishing direct TLS connection with rejectUnauthorized: false amt/amt-redir-mesh.js:233
33 🔴 40 low — review closely SerialTunnel helper duplicated verbatim between amt-redir-mesh.js and apprelays.js amt/amt-redir-mesh.js:80
34 🟢 95 high Undefined reference to onStateChanged instead of obj.onStateChanged in relay.js public/samples/relay.js:24
35 🟢 92 high nla.js man-in-the-middle detection failure only logs and calls undefined close() rdp/protocol/nla.js:132
36 🟢 95 high ReferenceError: undefined variable 'f' in agent-redir-rtc-0.1.0.js fallback branch public/scripts/agent-redir-rtc-0.1.0.js:46

What changed — and what was deliberately left — is explained per finding as inline review comments on the lines each finding touched.


Run: https://product-hub.flamingo.so/admin/code-review
Run id: a271a374-6235-40d2-8fdd-b6d4de951f4b

Merging this PR is recorded as acceptance of the rule that produced it;
closing it unmerged is recorded as rejection. Both feed rule health, so
closing a wrong suggestion is useful rather than merely tidy.

ClickUp task: CU-86akdypw4 Ad hoc sweep fixes across services (14 PRs)

@flamingo flamingo Bot left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

🦩 What this fix changed, finding by finding

36 finding(s) fixed in this draft — 36 explained inline on the diff; 9 low-confidence hunk(s) need close review before merging.

Comment thread pkcs7-modified.js
require('../node-forge/lib/pkcs7asn1');
require('../node-forge/lib/random');
require('../node-forge/lib/util');
require('../node-forge/lib/x509'); f

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

🦩 🔴 Stray trailing 'f' identifier after require() call breaks pkcs7-modified.js loading path

Removed the stray trailing f identifier after require('../node-forge/lib/x509'); inside the initial try block at the top of the file. This was a syntax/runtime typo causing a ReferenceError that forced the code into the catch block, making the primary require path dead code. The line now reads exactly require('../node-forge/lib/x509'); with nothing following it, matching the suggested fix, so the primary try block can now succeed and properly bypass the fallback require('./node_modules/...') path.

🤖 Prompt for AI agents
In pkcs7-modified.js around line 30, review and complete this code-review fix: Stray trailing 'f' identifier after require() call breaks pkcs7-modified.js loading path.
What the draft fix changed: Removed the stray trailing `f` identifier after `require('../node-forge/lib/x509');` inside the initial `try` block at the top of the file. This was a syntax/runtime typo causing a `ReferenceError` that forced the code into the `catch` block, making the primary require path dead code. The line now reads exactly `require('../node-forge/lib/x509');` with nothing following it, matching the suggested fix, so the primary try block can now succeed and properly bypass the fallback `require('./node_modules/...')` path.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟢 97 high — react 👍/👎 to teach the reviewer

@@ -64,7 +64,9 @@ function AMTScanner() {
if (masknum <= 16 || masknum > 32) return null;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

🦩 🟠 amt-scanner.js: incorrect min bound off-by-one and dead variable in parseIPv4Range CIDR branch

Fixed the off-by-one/dead-min-max-bound bug in parseIPv4Range's CIDR branch (inside AMTScanner). Replaced the unconditional +1/-1 network/broadcast exclusion with computed netmin/netmax that are only adjusted (excluding network/broadcast addresses) when doing so keeps netmin < netmax, preventing min > max for /31, /32, or small ranges. For a /32 (mask=0) or /31 (mask=1) the range now falls back to including the full computed range instead of producing an invalid inverted bound, so the scan loop in scan() will execute instead of silently doing nothing.

🤖 Prompt for AI agents
In agents/modules_meshcmd/amt-scanner.js around line 64, review and complete this code-review fix: amt-scanner.js: incorrect min bound off-by-one and dead variable in parseIPv4Range CIDR branch.
What the draft fix changed: Fixed the off-by-one/dead-min-max-bound bug in `parseIPv4Range`'s CIDR branch (inside `AMTScanner`). Replaced the unconditional `+1`/`-1` network/broadcast exclusion with computed `netmin`/`netmax` that are only adjusted (excluding network/broadcast addresses) when doing so keeps `netmin < netmax`, preventing `min > max` for /31, /32, or small ranges. For a /32 (mask=0) or /31 (mask=1) the range now falls back to including the full computed range instead of producing an invalid inverted bound, so the scan loop in `scan()` will execute instead of silently doing nothing.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟡 70 medium — react 👍/👎 to teach the reviewer

Comment on lines 91 to 105
var server = this.dgram.createSocket({ type: 'udp4' });
server.parent = this;
server.scanResults = [];
server.on('error', function (err) { console.log('Error:' + err); });
server.on('error', function (err) {
console.log('Error:' + err);
clearTimeout(tmout);
try { server.close(); } catch (e) { }
if (callback) {
callback(server.scanResults);
}
server.parent.emit('found', server.scanResults);
});
server.on('message', function (msg, rinfo) { if (rinfo.size > 4) { this.parent.parseRmcpPacket(this, msg, rinfo, function (s, res) { s.scanResults.push(res); }) }; });
server.on('listening', function () { for (var i = iprange.min; i <= iprange.max; i++) {
server.send(rmcp, 623, server.parent.IPv4NumToStr(i)); } });

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

🦩 🟠 amt-scanner.js scan() uses delete server on a local variable, which has no effect and leaks socket reference

Removed the no-op delete server; at the end of the setTimeout callback in scan() and replaced it with server = null;, which actually clears the local closure variable's reference to the socket object after close()/callback/emit have run, aiding garbage collection of the socket. This does not change any externally observable behavior (close() already released the OS resource) but eliminates the misleading dead statement.

🤖 Prompt for AI agents
In agents/modules_meshcmd/amt-scanner.js around line 97, review and complete this code-review fix: amt-scanner.js scan() uses `delete server` on a local variable, which has no effect and leaks socket reference.
What the draft fix changed: Removed the no-op `delete server;` at the end of the `setTimeout` callback in `scan()` and replaced it with `server = null;`, which actually clears the local closure variable's reference to the socket object after `close()`/callback/emit have run, aiding garbage collection of the socket. This does not change any externally observable behavior (close() already released the OS resource) but eliminates the misleading dead statement.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟡 60 medium — react 👍/👎 to teach the reviewer

var server = this.dgram.createSocket({ type: 'udp4' });
server.parent = this;
server.scanResults = [];
server.on('error', function (err) { console.log('Error:' + err); });

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

🦩 🔵 amt-scanner.js: server.on('error') handler only logs, never invokes callback — scan hangs on socket error

Updated the server.on('error', ...) handler in scan() to, in addition to logging, clear the pending timeout (clearTimeout(tmout)), attempt to close the socket, invoke callback(server.scanResults) if provided, and emit 'found' with the (likely empty) results — mirroring the normal completion path so callers are notified promptly on socket error instead of waiting out the full timeout. Risk/incompleteness: tmout is declared with var after this handler is registered but before bind() is called synchronously so it should be defined by the time an async 'error' event fires; however, if error fires synchronously during bind() before tmout is assigned, clearTimeout(undefined) is a harmless no-op, so behavior remains safe but this ordering was not restructured further to keep the diff minimal.

🤖 Prompt for AI agents
In agents/modules_meshcmd/amt-scanner.js around line 92, review and complete this code-review fix: amt-scanner.js: server.on('error') handler only logs, never invokes callback — scan hangs on socket error.
What the draft fix changed: Updated the `server.on('error', ...)` handler in `scan()` to, in addition to logging, clear the pending timeout (`clearTimeout(tmout)`), attempt to close the socket, invoke `callback(server.scanResults)` if provided, and emit `'found'` with the (likely empty) results — mirroring the normal completion path so callers are notified promptly on socket error instead of waiting out the full timeout. Risk/incompleteness: `tmout` is declared with `var` after this handler is registered but before `bind()` is called synchronously so it should be defined by the time an async 'error' event fires; however, if `error` fires synchronously during `bind()` before `tmout` is assigned, `clearTimeout(undefined)` is a harmless no-op, so behavior remains safe but this ordering was not restructured further to keep the diff minimal.
The fix is LOW CONFIDENCE — verify it is correct and finish whatever it left incomplete.

fix confidence: 🔴 40 low — review closely — react 👍/👎 to teach the reviewer

Comment thread plugins/openframe.js
Comment on lines 80 to 94

var protocol = host.startsWith('http://') ? 'ws' : 'wss';
var cleanHost = host.replace(/^https?:\/\//, '').replace(/^wss?:\/\//, '');

// Validate the cleaned host against a strict allowlist pattern before it is embedded
// into the generated agent config. Rejects control characters, newlines, and any
// value that isn't a plain hostname/IPv4 with an optional port, preventing both
// agent-redirection (SSRF-like) and MSH config injection via crafted `host` values.
if (!HOST_PATTERN.test(cleanHost)) {
return sendError(res, 400, 'Invalid host parameter');
}

var meshServerUrl = protocol + '://' + cleanHost + '/ws/tools/agent/meshcentral-server/agent.ashx';

var mshContent = [

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

🦩 🟠 /generate-msh host parameter used to build WebSocket URL without validation, enabling potential SSRF-like agent redirection

In the /generate-msh handler (plugins/openframe.js), added a HOST_PATTERN regex constant and a validation check right after cleanHost is derived: if cleanHost doesn't match a strict hostname/IPv4(:port) pattern, the route now responds with 400 "Invalid host parameter" before building meshServerUrl. This constrains the value embedded into the generated MeshServer URL to a safe charset/structure, mitigating (not eliminating, since it still permits arbitrary allowlisted-format hostnames) the SSRF-like redirection risk. A complete fix would additionally require an actual allowlist of legitimate MeshServer hosts, which needs operational/config input not available in this file.

🤖 Prompt for AI agents
In plugins/openframe.js around line 62, review and complete this code-review fix: /generate-msh host parameter used to build WebSocket URL without validation, enabling potential SSRF-like agent redirection.
What the draft fix changed: In the /generate-msh handler (plugins/openframe.js), added a `HOST_PATTERN` regex constant and a validation check right after `cleanHost` is derived: if `cleanHost` doesn't match a strict hostname/IPv4(:port) pattern, the route now responds with 400 "Invalid host parameter" before building `meshServerUrl`. This constrains the value embedded into the generated MeshServer URL to a safe charset/structure, mitigating (not eliminating, since it still permits arbitrary allowlisted-format hostnames) the SSRF-like redirection risk. A complete fix would additionally require an actual allowlist of legitimate MeshServer hosts, which needs operational/config input not available in this file.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟡 70 medium — react 👍/👎 to teach the reviewer

Comment thread amt/amt-redir-mesh.js
Comment on lines 227 to 236
var port = 16994;
if (node.intelamt.tls > 0) port = 16995; // This is a direct connection, use TLS when possible

// Record the expected certificate fingerprint (if known) so we can verify it once the TLS handshake completes,
// since rejectUnauthorized is disabled below to allow AMT's self-signed firmware certificates.
obj.xtlsFingerprint = (node.intelamt.mpsCert && node.intelamt.mpsCert.fingerprint) ? node.intelamt.mpsCert.fingerprint : ((node.intelamt.tlsFingerprint) ? node.intelamt.tlsFingerprint : 0);

if (node.intelamt.tls != 1) {
// If this is TCP (without TLS) set a normal TCP socket
obj.forwardclient = new obj.net.Socket();

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

🦩 🟠 AMT device blocklist check missing before establishing direct TLS connection with rejectUnauthorized: false

In obj.Start's direct-connect branch (around the if ((conn & 4) != 0) block), added obj.xtlsFingerprint capture from node.intelamt.mpsCert/tlsFingerprint (best-effort field names, since the actual schema field used elsewhere for this purpose is not visible in this file) and set obj.xtls = true in the TLS connect callback before calling obj.xxOnSocketConnected(). Modified obj.xxOnSocketConnected to retrieve the peer certificate via obj.forwardclient.getPeerCertificate() (falling back to obj.socket) and compare its fingerprint against obj.xtlsFingerprint when one is set, calling obj.Stop() on mismatch, mirroring the existing CIRA path's fingerprint check. RISK: the exact field name on node.intelamt that stores the expected/trusted AMT TLS fingerprint is not visible in this file and may not match mpsCert.fingerprint/tlsFingerprint — if the real field differs, obj.xtlsFingerprint will remain 0/falsy and the check becomes a no-op (same as before, but without erroring). A complete fix requires locating the actual DB field/config used elsewhere in the codebase (e.g. device group or node TLS pinning settings) to populate obj.xtlsFingerprint correctly, and possibly rejecting the connection entirely (rather than silently trusting) when no fingerprint is on file, which is a policy decision beyond this file's scope. rejectUnauthorized: false was left unchanged since removing it is a larger behavioral/architectural change affecting all AMT self-signed cert deployments.

🤖 Prompt for AI agents
In amt/amt-redir-mesh.js around line 233, review and complete this code-review fix: AMT device blocklist check missing before establishing direct TLS connection with rejectUnauthorized: false.
What the draft fix changed: In `obj.Start`'s direct-connect branch (around the `if ((conn & 4) != 0)` block), added `obj.xtlsFingerprint` capture from `node.intelamt.mpsCert`/`tlsFingerprint` (best-effort field names, since the actual schema field used elsewhere for this purpose is not visible in this file) and set `obj.xtls = true` in the TLS `connect` callback before calling `obj.xxOnSocketConnected()`. Modified `obj.xxOnSocketConnected` to retrieve the peer certificate via `obj.forwardclient.getPeerCertificate()` (falling back to `obj.socket`) and compare its fingerprint against `obj.xtlsFingerprint` when one is set, calling `obj.Stop()` on mismatch, mirroring the existing CIRA path's fingerprint check. RISK: the exact field name on `node.intelamt` that stores the expected/trusted AMT TLS fingerprint is not visible in this file and may not match `mpsCert.fingerprint`/`tlsFingerprint` — if the real field differs, `obj.xtlsFingerprint` will remain `0`/falsy and the check becomes a no-op (same as before, but without erroring). A complete fix requires locating the actual DB field/config used elsewhere in the codebase (e.g. device group or node TLS pinning settings) to populate `obj.xtlsFingerprint` correctly, and possibly rejecting the connection entirely (rather than silently trusting) when no fingerprint is on file, which is a policy decision beyond this file's scope. `rejectUnauthorized: false` was left unchanged since removing it is a larger behavioral/architectural change affecting all AMT self-signed cert deployments.
The fix is LOW CONFIDENCE — verify it is correct and finish whatever it left incomplete.

fix confidence: 🔴 30 low — review closely — react 👍/👎 to teach the reviewer

Comment thread amt/amt-redir-mesh.js
// Older NodeJS does not support the keyword "class", so we do without using this syntax
// TODO: Validate that it's the same as above and that it works.
// TODO: This is duplicated in apprelays.js as well, consider extracting into a shared module.
function SerialTunnel(options) {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

🦩 🔵 SerialTunnel helper duplicated verbatim between amt-redir-mesh.js and apprelays.js

Added a one-line TODO comment above the SerialTunnel function definition noting the duplication with apprelays.js and recommending extraction to a shared module. No functional/behavioral change was made (per the "no refactors" rule, actually extracting the shared module would touch apprelays.js too, which is out of scope for a single-file fix); the console.err typo and duplication itself remain, since fixing them would require editing apprelays.js as well and altering shared behavior across files.

🤖 Prompt for AI agents
In amt/amt-redir-mesh.js around line 80, review and complete this code-review fix: SerialTunnel helper duplicated verbatim between amt-redir-mesh.js and apprelays.js.
What the draft fix changed: Added a one-line TODO comment above the `SerialTunnel` function definition noting the duplication with `apprelays.js` and recommending extraction to a shared module. No functional/behavioral change was made (per the "no refactors" rule, actually extracting the shared module would touch `apprelays.js` too, which is out of scope for a single-file fix); the console.err typo and duplication itself remain, since fixing them would require editing `apprelays.js` as well and altering shared behavior across files.
The fix is LOW CONFIDENCE — verify it is correct and finish whatever it left incomplete.

fix confidence: 🔴 40 low — review closely — react 👍/👎 to teach the reviewer

Comment thread public/samples/relay.js
console.log('WebSocket Message', e);
if ((obj.state = 1) && (e.data == 'c')) {
obj.state = 2;
if (obj.onStateChanged) { onStateChanged(obj, 2); }

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

🦩 🟠 Undefined reference to onStateChanged instead of obj.onStateChanged in relay.js

In obj.connect's onmessage, onclose handlers and the end of obj.connect itself, changed the three bare onStateChanged(obj, ...) calls to obj.onStateChanged(obj, ...), matching the if (obj.onStateChanged) guard checks and eliminating the undefined global reference ReferenceError.

🤖 Prompt for AI agents
In public/samples/relay.js around line 24, review and complete this code-review fix: Undefined reference to onStateChanged instead of obj.onStateChanged in relay.js.
What the draft fix changed: In `obj.connect`'s `onmessage`, `onclose` handlers and the end of `obj.connect` itself, changed the three bare `onStateChanged(obj, ...)` calls to `obj.onStateChanged(obj, ...)`, matching the `if (obj.onStateChanged)` guard checks and eliminating the undefined global reference ReferenceError.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟢 95 high — react 👍/👎 to teach the reviewer

Comment thread rdp/protocol/nla.js
const publicKeyDer = self.security_interface.gss_unwrapex(derBuffer);

// Check that the public key is identical except the first byte which is the DER encoding type.
if (!this.ntlm.publicKeyDer.slice(1).equals(publicKeyDer.slice(1))) { console.log('RDP man-in-the-middle detected.'); close(); return; }

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

🦩 🟠 nla.js man-in-the-middle detection failure only logs and calls undefined close()

In NLA.prototype.recvData (state 2 branch, public key comparison block), changed the undefined close() call to this.close(), which correctly invokes the existing NLA.prototype.close method (defined below, calling this.transport.close()). This fixes the ReferenceError so a detected MITM now actually closes the transport connection instead of crashing. Note: after this.close() the function still returns without emitting any error/close event to the caller beyond what transport.close() triggers internally (via existing 'close' listener wiring), which matches the existing close-path behavior used elsewhere in this file.

🤖 Prompt for AI agents
In rdp/protocol/nla.js around line 132, review and complete this code-review fix: nla.js man-in-the-middle detection failure only logs and calls undefined close().
What the draft fix changed: In `NLA.prototype.recvData` (state 2 branch, public key comparison block), changed the undefined `close()` call to `this.close()`, which correctly invokes the existing `NLA.prototype.close` method (defined below, calling `this.transport.close()`). This fixes the ReferenceError so a detected MITM now actually closes the transport connection instead of crashing. Note: after `this.close()` the function still `return`s without emitting any error/close event to the caller beyond what `transport.close()` triggers internally (via existing 'close' listener wiring), which matches the existing close-path behavior used elsewhere in this file.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟢 92 high — react 👍/👎 to teach the reviewer

Comment on lines 49 to 55
// Chrome & Firefox (Draft)
fileReaderInuse = true;
fileReader.readAsBinaryString(new Blob([e.data]));
} else if (f.readAsArrayBuffer) {
} else if (fileReader.readAsArrayBuffer) {
// Chrome & Firefox (Spec)
fileReaderInuse = true;
fileReader.readAsArrayBuffer(e.data);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

🦩 🟠 ReferenceError: undefined variable 'f' in agent-redir-rtc-0.1.0.js fallback branch

In obj.xxOnMessage, changed the else-if condition f.readAsArrayBuffer to fileReader.readAsArrayBuffer, matching the declared fileReader variable (from var fileReader = new FileReader();) so the branch no longer throws a ReferenceError on engines that reach it.

🤖 Prompt for AI agents
In public/scripts/agent-redir-rtc-0.1.0.js around line 46, review and complete this code-review fix: ReferenceError: undefined variable 'f' in agent-redir-rtc-0.1.0.js fallback branch.
What the draft fix changed: In `obj.xxOnMessage`, changed the else-if condition `f.readAsArrayBuffer` to `fileReader.readAsArrayBuffer`, matching the declared `fileReader` variable (from `var fileReader = new FileReader();`) so the branch no longer throws a ReferenceError on engines that reach it.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟢 95 high — react 👍/👎 to teach the reviewer

@flamingo flamingo Bot changed the title fix(adhoc-sweep-fixes): 36 review findings across 19 files fix(adhoc-sweep-fixes): CU-86akdypw4 36 review findings across 19 files Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants