[Bug] --search-depth accepts non-integer values, resulting in NaN depth and unbounded recursive directory traversal
Maintainers usually reply within 2 days
A pull request for this has already been merged.
- #1535 by @coder-Yash886 — merged
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- node.js, typescript
Research direction
Read src/cli/validate.ts and follow how --batch-size is validated; compare that with how searchDepth is used in src/index.ts and src/scan/single-scan.ts. Check the depth guard in src/utils/file.ts and add or run focused validation tests if present. Done means invalid values such as abc and 1.5 are rejected before scanning, while valid non-negative integers work.
Written by the indexing model from the issue text.
Description
Summary
--search-depth accepts non-integer and non-numeric inputs (such as --search-depth abc, --search-depth 1.5, or --search-depth=foo) without validation.
In src/index.ts and src/scan/single-scan.ts, the search depth is calculated as:
const searchDepth = Math.max(0, Number(options.searchDepth || DEFAULT_SEARCH_DEPTH));
When a non-numeric string is provided, Number(options.searchDepth) evaluates to NaN, making searchDepth equal NaN.
This value is passed down to findFiles(rootDir, names, maxDepth) in src/utils/file.ts, where directory recursion is controlled by:
function walk(currentDir: string, depth: number) {
if (depth > maxDepth) return;
// ...
Because depth > NaN evaluates to false for any depth level in JavaScript (e.g. 10 > NaN is false), the recursion guard is completely bypassed. As a result, the scanner performs unbounded directory traversal into nested directory trees, completely ignoring depth limits. In addition, searchDepth: NaN is recorded into the --json report provenance.
While --batch-size is explicitly validated in src/cli/validate.ts (must be a positive integer), --search-depth has no validation in validateOptions.
Environment
- OS: Linux / macOS / Windows
- Node.js version: >= 22.0.0
- Package manager: npm
- Lockfile type: any
- CVE Lite CLI version: 1.40.0
Command used
cve-lite . --offline --search-depth abc
Expected behavior
The CLI should validate --search-depth and reject non-negative integer violations before starting the scan, matching the pattern of --batch-size:
Error: --search-depth must be a non-negative integer
Actual behavior
The CLI accepts --search-depth abc silently, sets searchDepth to NaN, bypasses depth limiting in findFiles, and traverses arbitrarily deep nested folders.
Reproduction
- In a directory with deeply nested folders (e.g. depth > 4):
node dist/index.js . --offline --search-depth abc - Observe that
validateOptionsdoes not throw, and files located beyond the default depth 4 are scanned becausedepth > NaNnever terminates recursion early.
Relevant files or output
src/cli/validate.ts:--search-depthis missing fromvalidateOptions.src/utils/file.ts(line 22):if (depth > maxDepth) return;fails to terminate whenmaxDepthisNaN.src/index.ts(line 68) &src/scan/single-scan.ts:searchDepthevaluates toNaN.
- Dominant language
- TypeScript
- Stars
- 786
- Forks
- 189
- Avg merge
- 3d 10h
- Merged PRs (30d)
- 98
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from OWASP/cve-lite-cli
-
[Bug] --rule silently accepts unrecognised or lowercase rule IDs, masking override findings and exiting 0Possibly taken @coder-Yash886 claimed this 2 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
OWASP/cve-lite-cli#1536 · 1 comment ·
Maintainers usually reply within 2 days
-
[Bug] --base accepts another flag as its branch name and drops --offlinePossibly taken @vianmangal claimed this 12 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
OWASP/cve-lite-cli#1430 · 1 comment · 1 reaction ·
Maintainers usually reply within 2 days
-
CVE Lite CLI — Public Adoption TrackerMay be free again @Darshan3690 claimed this 13 days ago, and no pull request is open. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
OWASP/cve-lite-cli#1396 · 2 comments ·
Maintainers usually reply within 2 days
-
chore: fix TypeScript code quality violations from May 2026 auditPossibly taken @dyk1454683243-sudo claimed this 50 days ago. Openenhancement good first issue help wanted refactor
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
OWASP/cve-lite-cli#420 · 21 comments ·
Maintainers usually reply within 2 days
-
OA010 message repeats a version once per advisoryPossibly taken @HarshRajSinghania claimed this today. Openbug good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
OWASP/cve-lite-cli#1560 ·
Maintainers usually reply within 2 days
All issues in OWASP/cve-lite-cli
Similar issues
-
clawsweeper:needs-maintainer-review clawsweeper:needs-product-decision clawsweeper:no-new-fix-pr clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster P2
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
openclaw/openclaw#195577 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
EKKOLearnAI/ekko-studio#3729 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 1-3 hours Newbie friendliness 78/100
Supportseal/SupportSeal-app#98 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
eliasstravik/herdr-projects#845 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
cloudflare/skills#279 ·
Maintainers usually reply within 1 day