awslabs / ar-go-tools

ar-go-tools (Argot) is a collection of analysis tools for Go
Apache License 2.0
5 stars 1 forks source link

Use of Insecure Functions #38

Closed victornicolet closed 3 months ago

victornicolet commented 8 months ago

The source code relies heavily on risky fmt.Printf usage with untrusted input that is not explicitly sanitized. As a result, usage of analysis tools on malicious packages may lead to vulnerabilities such as terminal escape injection. This could allow an attacker to gain control over a user's system.

While not all of the calls to risky library functions may be directly exploitable, it is considered industry best practice to consistently validate input originating from untrusted sources. A simple method for accomplishing this goal when using fmt is to replace the usage of %s with %q. The latter will interpret the provided string as a double quoted and safely escaped Go string. Note that this may cause unintended display issues in some cases where special formatting is desired, and QA testing should be performed after these changes to verify that output for each case was not negatively impacted. In cases where replacing %s with %q has a negative impact on desired format, a more in depth custom sanitization approach should be utilized. For example, strings could be examined for byte sequences before being passed to format print functions.

github-actions[bot] commented 4 months ago

Stale issue message