Togoder security

npm package security report

yargs@18.0.0 security report

Risky patterns found that deserve a look.

Needs review Version 18.0.0 Files reviewed 25 Size 159.0 KB Scanned

Summary

Togoder Security scanned the npm package yargs@18.0.0 on Oct 6, 2026. An AI review of 25 source files produced 2 medium, 6 low severity findings. The overall verdict is medium: the findings flag risky but common patterns (dynamic code, unsafe defaults, broad file or network access) rather than confirmed malware.

0
critical
0
high
2
medium
6
low

Findings 8

medium

Dynamic module loading with external input

NPS-E9D8AE43AB53

The function uses import.meta.resolve() and _shim.require() to load modules based on the 'extends' property from a configuration object, which could potentially load malicious modules if the config is attacker-controlled. However, this is likely intentional functionality for extending configs.

build/lib/utils/apply-extends.js
medium

File system access

NPS-3725904A191F

Reads files using shim.readFileSync() based on paths derived from configuration. The path resolution uses shim.path.resolve() with a provided cwd, which could read files outside the package scope if paths contain directory traversal sequences.

build/lib/utils/apply-extends.js
low

Prototype pollution protection

NPS-B8BF0BDBF290

The mergeDeep function uses Object.assign and recursive merging but does not explicitly protect against prototype pollution (e.g., __proto__, constructor, prototype keys). An attacker-controlled config could potentially pollute Object.prototype.

build/lib/utils/apply-extends.js
low

Reading files and directories

NPS-BDD4991EE576

The module imports readFileSync and readdirSync from node:fs and exports them. This provides file system access to consumers of this module. While not malicious by itself, it could be a vector if the library is used by untrusted code. The y18n initialization also reads locale files from a resolved path outside the package's immediate directory (../../../locales), which is a relative path traversal outside the package scope. However, this is a common pattern for i18n libraries and the updateFiles option is set to false, preventing writes.

lib/platform-shims/esm.mjs:13
low

Path traversal / directory traversal in mainFilename computation

NPS-A7D370047B0D

The code computes mainFilename by taking __dirname and truncating it at the last occurrence of 'node_modules'. This logic assumes the package is installed inside node_modules. If the package is installed outside node_modules or in a symlinked environment (e.g., pnpm, yarn PnP, or globally), mainFilename may resolve to an unexpected path or be empty. This is not directly malicious but could lead to incorrect behavior or information disclosure about the filesystem structure. It also reveals the package expects to run within a specific directory structure.

lib/platform-shims/esm.mjs:16
low

Dynamic module loading / require creation

NPS-76184522C2E0

The code uses createRequire to create a require function relative to the current module. This is a common pattern in ESM modules to access CommonJS modules. While dynamic require can be a red flag for dynamic code execution, here it is used statically and does not accept external input. It is exported as part of the default object, which could be misused by consumers, but the module itself does not perform any dynamic loading with computed paths.

lib/platform-shims/esm.mjs:17
low

Environment variable access

NPS-370B0831C6AC

The exported getEnv function allows reading arbitrary environment variables via process.env[key]. While this is a common utility, it could be leveraged by an attacker if the consumer of this module passes untrusted input to getEnv, potentially exposing sensitive environment variables. However, this is a standard pattern in many CLI libraries and not inherently malicious.

lib/platform-shims/esm.mjs:22
low

Caller file resolution with get-caller-file

NPS-55BE5AAD1671

The getCallerFile function uses getCallerFile(3) to determine the calling file and normalizes file:// URLs. This is a common pattern for libraries that need to resolve paths relative to the caller. It does not execute code or access sensitive information directly, but it does inspect the call stack, which could be used for reconnaissance if the library is compromised. In this context, it appears benign.

lib/platform-shims/esm.mjs:58

Files reviewed

FileVerdictWhat the reviewer saw
build/lib/utils/apply-extends.js medium The code implements configuration extension with file and module loading based on user-supplied config, presenting potential risks if input is not validated, but no overtly malicious patterns like exfiltration or command execution are present.
lib/platform-shims/esm.mjs medium The code is a platform shim for an ESM environment, providing common utilities and imports; no overtly malicious patterns such as data exfiltration, credential harvesting, or dynamic code execution were detected, but it does expose environment variable access, file system operations, and dynamic require creation which could be misused by consumers.
browser.mjs safe Cleared by Jev triage; no further analysis needed
build/lib/argsert.js safe Cleared by Jev triage; no further analysis needed
build/lib/command.js safe No malicious patterns detected
build/lib/completion-templates.js safe This file contains static shell completion script templates with placeholder substitutions and no executable, network, or filesystem-mutating code.
build/lib/completion.js safe No malicious patterns detected
build/lib/middleware.js safe No malicious patterns detected; the code implements yargs middleware management with no network, filesystem, process, or dynamic code execution activity.
build/lib/parse-command.js safe No malicious patterns detected
build/lib/typings/common-types.js safe Cleared by Jev triage; no further analysis needed
build/lib/typings/yargs-parser-types.js safe Cleared by Jev triage; no further analysis needed
build/lib/usage.js safe No malicious patterns detected; the code is a standard usage/help formatting module for the yargs CLI library with no network, credential, process spawning, or obfuscated behavior.
build/lib/utils/is-promise.js safe Cleared by Jev triage; no further analysis needed
build/lib/utils/levenshtein.js safe No malicious patterns detected
build/lib/utils/maybe-async-result.js safe Cleared by Jev triage; no further analysis needed
build/lib/utils/obj-filter.js safe Cleared by Jev triage; no further analysis needed
build/lib/utils/process-argv.js safe Cleared by Jev triage; no further analysis needed
build/lib/utils/set-blocking.js safe No malicious patterns detected
build/lib/utils/which-module.js safe Cleared by Jev triage; no further analysis needed
build/lib/validation.js safe No malicious patterns detected; the file contains standard yargs argument-validation logic without exfiltration, obfuscation, or dynamic code execution.
build/lib/yargs-factory.js safe No malicious patterns detected; this is a legitimate yargs command-line argument parsing library factory with no exfiltration, credential harvesting, obfuscation, or backdoor behavior.
build/lib/yerror.js safe Cleared by Jev triage; no further analysis needed
helpers/helpers.mjs safe Cleared by Jev triage; no further analysis needed
index.mjs safe Cleared by Jev triage; no further analysis needed
lib/platform-shims/browser.mjs safe No malicious patterns detected

Affected version ranges

None of the 3 scanned versions of yargs are flagged high or critical. The latest scanned version, 18.0.0, is medium risk. Only versions we have scanned are listed; unscanned versions between them are not covered.

7.1.218.0.0
VersionsVerdictCountRangeTop findings
18.0.0 Needs review 1 18.0.0 Dynamic module loading with external input; File system access
17.7.2 – 17.7.3 Not scanned 2 >=17.7.2 <=17.7.3
15.4.1 – 16.2.0 Needs review 2 >=15.4.1 <=16.2.0 dynamic module loading from external URL; Dynamic module loading from user-controlled input
7.1.2 Not scanned 1 7.1.2

Full list, including published versions not scanned yet: version ranges API.

Scanned versions of yargs

VersionVerdictFilesScanned
18.0.0 Needs review 25 Oct 6, 2026
16.2.0 Needs review 26 Oct 6, 2026
15.4.1 Needs review 18 Oct 4, 2026

Frequently asked questions

Is yargs safe to use?

No confirmed malware was found in yargs@18.0.0, but the review flagged 2 medium, 6 low severity findings for risky patterns worth checking before you rely on it.

Does yargs contain malware?

No malware was identified in yargs@18.0.0 when Togoder Security scanned it on Oct 6, 2026. A new version can still introduce malicious code, so scan the exact versions in your lockfile.

How was yargs checked?

Togoder Security downloaded the published npm package and had an AI model read its 25 source files, looking for install scripts, credential access, network exfiltration, obfuscation, backdoors and crypto-wallet theft. The results are cached by file hash and shown here.

How do I scan yargs together with the rest of my dependencies?

Upload your lockfile at https://security.togoder.click/scan or call the API documented at https://security.togoder.click/api-docs. Files that have already been scanned, like the ones in yargs@18.0.0, cost nothing.

Related security reports