Skip to content

[deft-security] Fix 4 vulnerabilities in src/cache.c#27

Open
539hex wants to merge 1 commit intomainfrom
deft-security/src-cache.c-5d633582
Open

[deft-security] Fix 4 vulnerabilities in src/cache.c#27
539hex wants to merge 1 commit intomainfrom
deft-security/src-cache.c-5d633582

Conversation

@539hex
Copy link
Copy Markdown
Owner

@539hex 539hex commented Feb 10, 2026

Security Fixes

File: src/cache.c
Highest Severity: MEDIUM
Fixes Applied: 4

CWE-367: Time-of-check Time-of-use (TOCTOU) Race Condition

  • Severity: MEDIUM
  • Confidence: 88%
  • The function get_from_cache() returns a pointer to a DataItem while releasing the mutex. Another thread could modify or delete this item after the mutex is unlocked but before the caller uses it, leading to use-after-free or data corruption.

CWE-190: Integer Overflow or Wraparound

  • Severity: MEDIUM
  • Confidence: 90%
  • Casting time(NULL) to unsigned int can cause integer overflow. The subtraction on line 63 (time(NULL) - item->last_accessed) will produce incorrect results when time_t is 64-bit and wraps around the unsigned int boundary.

CWE-190: Integer Overflow or Wraparound

  • Severity: MEDIUM
  • Confidence: 92%
  • Casting time(NULL) to unsigned int can cause integer overflow on systems where time_t is 64-bit (most modern systems). After year 2106, this will wrap around to 0, breaking cache expiration logic.

CWE-476: NULL Pointer Dereference

  • Severity: LOW
  • Confidence: 75%
  • If hash_table_insert() fails or hash_table_search() returns NULL after insertion (due to memory issues or hash collision handling), dereferencing item without checking could cause a crash. While unlikely, defensive programming should verify the pointer.

Automated by deft.is code scanning

CWE-367: Time-of-check Time-of-use (TOCTOU) Race Condition, CWE-190: Integer Overflow or Wraparound, CWE-476: NULL Pointer Dereference

Automated security fix by deft.is
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.

1 participant