Skip to content

Fix critical false negative in check command on first run#6

Closed
Mehran-Seifalinia wants to merge 1 commit into
projectdiscovery:mainfrom
Mehran-Seifalinia:patch-1
Closed

Fix critical false negative in check command on first run#6
Mehran-Seifalinia wants to merge 1 commit into
projectdiscovery:mainfrom
Mehran-Seifalinia:patch-1

Conversation

@Mehran-Seifalinia

@Mehran-Seifalinia Mehran-Seifalinia commented Jun 13, 2026

Copy link
Copy Markdown

Fix a critical false negative in the check command (and default invocation) on the very first run after installation or cache clearance.

Problem

When a user runs depx check <package> for the first time (no existing local index), the command does not wait for the malicious‑package index to finish downloading. Instead, it immediately queries the intelProvider, which may return not_found or clean because the background sync is still in progress.

Impact: A package that is actually malicious can be reported as safe (false negative). This undermines supply‑chain security in CI/CD pipelines and local audits.

Why it wasn't caught: Existing e2e tests always prime the cache via search or feed before testing check. No test covers a cold‑cache check invocation.

Solution

Add an explicit readiness check before creating the check.Service:

  • Call intelProvider.SyncStatus().
  • If LastSuccess.IsZero() (no successful sync yet), show a spinner "Downloading malicious package index…" and block on intelProvider.WaitBackgroundSync() until the index is fully downloaded.
  • Only then proceed with the actual package checks.

Changes: cli/check.go – insert the readiness block right after the advisory‑ID branch and before check.NewService.

- Add index readiness check before performing package checks
- If no successful sync yet, wait for background index download using WaitBackgroundSync()
- Prevents returning "clean" or "not_found" while index is still downloading
@neo-by-projectdiscovery

neo-by-projectdiscovery Bot commented Jun 13, 2026

Copy link
Copy Markdown

Neo - PR Security Review

No security issues found

Comment @pdneo help for available commands. · Open in Neo

@neo-by-projectdiscovery-dev

neo-by-projectdiscovery-dev Bot commented Jun 13, 2026

Copy link
Copy Markdown

Neo - PR Security Review

No security issues found

Comment @pdneo help for available commands. · Open in Neo

@Mehran-Seifalinia

Copy link
Copy Markdown
Author

@pdneo review

@ehsandeep ehsandeep left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hey, Thanks for PR, but I'm unabel to reproduce what you reported, can you share more details?

$ rm -rf ~/.cache/depx
$ depx apkeep         

       __               
  ____╱ ╱__  ____  _  __
 ╱ __  ╱ _ ╲╱ __ ╲│ │╱_╱
╱ ╱_╱ ╱  __╱ ╱_╱ ╱>  <  
╲__,_╱╲___╱ .___╱_╱│_│  
         ╱_╱            v0.1.0

[MAL-2026-3431] MALICIOUS · apkeep (PyPI) · 32d
  ↳ Package: https://pypi.org/project/apkeep/
  ↳ OSV: https://osv.dev/vulnerability/MAL-2026-3431

@Mehran-Seifalinia Mehran-Seifalinia closed this by deleting the head repository Jun 13, 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.

2 participants