Resource Leak Medium

Failing to properly handle resources like files and network connections can lead to availability or exploitation issues - not closing file handles opened via os.Open/Create/OpenFile exhausts available handles over time, causing denial of service through lack of file access, while dynamically defined httptrace.ClientTrace objects allow arbitrary remote code execution by deserializing untrusted data into executable code during requests; to prevent resource exhaustion and potential remote attacks, files should be closed immediately after use through defer statements or helpers to ensure handles are released, and httptrace traces should be static and hardcoded to avoid dynamic deserialization of malicious payloads - proper resource handling through prompt cleanup and avoiding dynamic definitions prevents both availability problems and potential security exploits.

Detector ID
go/resource-leak@v1.0
Category