Reliance on untrusted inputs in a security decision
Description
The function g_get_home_dir is synonymous with getenv("HOME") and should be treated as untrusted input as it could be modified by an attacker. Possible risks include: the value being too large and causing buffer overflows, files under the attacker's control being used maliciously, or files outside of an attacker's control becoming accessible, depending on access privileges.
Examples
Insecure Code
c
char* home_dir = g_get_home_dir();Secure Code
c
char* home_dir = g_get_home_dir(); if (home_dir != NULL && strlen(home_dir) < 1024) { /* use home_dir */ }Remediation
Validate and sanitize the input from g_get_home_dir to prevent potential security risks.
Rule Details
| Field | Value |
|---|---|
| ID | CODE-0564 |
| Category | Injection |
| Severity | HIGH |
| CWE | CWE-807 |
| Confidence | HIGH |
| Impact | HIGH |
| Likelihood | MEDIUM |
| Exploitability | MODERATE |
| Tags | injection, untrusted input |
| OWASP | A1:2017-Injection, A03:2021-Injection |