MCPcopy Create free account
hub / github.com/WJX20/claude-code / checkDownloadUtilities

Function checkDownloadUtilities

src/tools/PowerShellTool/powershellSecurity.ts:276–315  ·  view source on GitHub ↗

* Checks for standalone download utilities — LOLBAS tools commonly used to * fetch payloads. Unlike checkDownloadCradles (which requires download + IEX * in-pipeline), this flags the download operation itself. * * Start-BitsTransfer: always a file transfer (MITRE T1197). * certutil -urlcache: c

(
  parsed: ParsedPowerShellCommand,
)

Source from the content-addressed store, hash-verified

274 * bitsadmin /transfer: legacy BITS download (pre-PowerShell).
275 */
276function checkDownloadUtilities(
277 parsed: ParsedPowerShellCommand,
278): PowerShellSecurityResult {
279 for (const cmd of getAllCommands(parsed)) {
280 const lower = cmd.name.toLowerCase()
281 // Start-BitsTransfer is purpose-built for file transfer — no safe variant.
282 if (lower === 'start-bitstransfer') {
283 return {
284 behavior: 'ask',
285 message: 'Command downloads files via BITS transfer',
286 }
287 }
288 // certutil / certutil.exe — only when -urlcache is present. certutil has
289 // many non-download uses (cert store queries, encoding, etc.).
290 // certutil.exe accepts both -urlcache and /urlcache per standard Windows
291 // utility convention — check both forms (bitsadmin below does the same).
292 if (lower === 'certutil' || lower === 'certutil.exe') {
293 const hasUrlcache = cmd.args.some(a => {
294 const la = a.toLowerCase()
295 return la === '-urlcache' || la === '/urlcache'
296 })
297 if (hasUrlcache) {
298 return {
299 behavior: 'ask',
300 message: 'Command uses certutil to download from a URL',
301 }
302 }
303 }
304 // bitsadmin /transfer — legacy BITS CLI, same threat as Start-BitsTransfer.
305 if (lower === 'bitsadmin' || lower === 'bitsadmin.exe') {
306 if (cmd.args.some(a => a.toLowerCase() === '/transfer')) {
307 return {
308 behavior: 'ask',
309 message: 'Command downloads files via BITS transfer',
310 }
311 }
312 }
313 }
314 return { behavior: 'passthrough' }
315}
316
317/**
318 * Checks for Add-Type usage which compiles and loads .NET code at runtime.

Callers

nothing calls this directly

Calls 1

getAllCommandsFunction · 0.50

Tested by

no test coverage detected