Repository navigation
KES/EDR blocks "Open with" on Windows: powershell.exe + temp associations.ps1 with inline C# trips "PowerShell accesses Native API" #13188
IichiKohuro
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
0.2.2-rc.2(file version0.2.2-rc.2, product version0.2.2.0)desktop26200.9550, x6412.8.0.505, managed by Kaspersky Security Center Agent15.1.0.20748Ready-to-post for GitHub Discussions
Title:
Body:
Summary
On Windows, the file-card action Open with / Open makes the Host enumerate registered Shell association handlers.
@deepseek-ai/dsh-native-commanddoes this by writing%TEMP%\dsh-native-command-XXXXXX\associations.ps1— a script with embedded C# andDllImport("shell32.dll")— and executing it aspowershell.exe -NoProfile -NonInteractive -STA -ExecutionPolicy Bypass -File <script>.Kaspersky Endpoint Security's behavior detection blocks exactly this pattern ("PowerShell обращается к Native API" / "PowerShell accesses Native API", heuristic). Result: the application list never appears, the action fails silently for the user, and the corporate SOC gets an alert each time.
This is a false positive in intent, but the pattern is inherently flagged: temp-dir script +
-ExecutionPolicy Bypass+ runtime C# compilation +shell32P/Invoke is also the shape of many malicious loaders.Steps to reproduce
Observed event (verbatim, translated field names)
Root cause (verified in the installed
app.asar)node_modules/@deepseek-ai/dsh-native-command(file-association helpers), roughly:The embedded C# exposes
[DshFileAssociations]::List($path)(enumerate handlers) and[DshFileAssociations]::Open($path, $application)(launch the chosen handler) usingSHAssocEnumHandlers/SHCreateItemFromParsingName/IDataObject/ShellExecute.Consumers found in the same
asar:@deepseek-ai/dsh-api-session-controller—sessionController.fileApplications = nativeFileApplications,openFileApplication = openNativeFileApplication,openPath = openNativeAssociatedPath,revealPath = revealNativePath; gated bycanOpenPath() = config.nativeOpen ?? platform default. This is the path used by the Web file card / context menu (ui-file-actions,ui-open-in-app).@deepseek-ai/dsh-host-open-in-app— uses "the PowerShell extraction on Windows" for application icon extraction, i.e. the same PowerShell bridge shape for another purpose.Impact
Suggested fixes (in order of preference)
.exeor N-API addon), or avoid runtime C# entirely: a first-pass application list fromHKEY_CLASSES_ROOT\<ext>\OpenWithProgids+HKEY_CLASSES_ROOT\Applications\*registry reads covers most cases, with the Shell API only as a fallback.-ExecutionPolicy Bypass+ temp-dir script + inline C# for shipped product functionality; that triple is a recognized malware pattern and is what the heuristic keys on.nativeOpen: falsecurrently disables the whole native open/reveal path. Consider a separate switch for association enumeration (fileApplications), so users can keep "Reveal in Explorer" without the handler list.Workaround confirmed by the user's side
canOpenPath()becomesfalse, the native open/reveal actions stop being offered, and no PowerShell process is spawned. Side effect: file-card "Open with" disappears entirely.Additional observations
finally, so an AV product cannot keep or submit the sample afterwards — blocking happens purely from process behavior.-EncodedCommanddue to the 32767-character CreateProcess limit). The issue is the chosen transport, not the code quality.resources/app.asar→node_modules/@deepseek-ai/dsh-native-command; theasarindex also listsdsh-native-commandas a dependency of the CLI package.Question for maintainers: is this a known limitation of 0.2.2-rc.2, and is there a
supported way to enumerate file associations without the PowerShell bridge?
All reactions