Skip to content

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

FieldValue
IDCODE-0564
CategoryInjection
SeverityHIGH
CWECWE-807
ConfidenceHIGH
ImpactHIGH
LikelihoodMEDIUM
ExploitabilityMODERATE
Tagsinjection, untrusted input
OWASPA1:2017-Injection, A03:2021-Injection