Skip to content

Master C and C++ with our new Testing Handbook chapter#2111

Open
carlospolop wants to merge 1 commit intomasterfrom
update_Master_C_and_C___with_our_new_Testing_Handbook_cha_20260409_133740
Open

Master C and C++ with our new Testing Handbook chapter#2111
carlospolop wants to merge 1 commit intomasterfrom
update_Master_C_and_C___with_our_new_Testing_Handbook_cha_20260409_133740

Conversation

@carlospolop
Copy link
Copy Markdown
Collaborator

🤖 Automated Content Update

This PR was automatically generated by the HackTricks News Bot based on a technical blog post.

📝 Source Information

  • Blog URL: https://blog.trailofbits.com/2026/04/09/master-c-and-c-with-our-new-testing-handbook-chapter/
  • Blog Title: Master C and C++ with our new Testing Handbook chapter
  • Suggested Section: Generic Methodologies & Resources -> Source code Review / SAST Tools (or create/add under a Secure Code Review subsection for C/C++ gotchas); additionally cross-link from Pentesting Web -> Command Injection (system()/shelling-out pitfalls) and Windows Local Privilege Escalation/Windows security notes for CreateProcess unquoted path & WorstFit path issues

🎯 Content Summary

What this post is
Trail of Bits announces a new Testing Handbook chapter: a comprehensive security checklist for C and C++ code, aimed primarily at manual source review (as opposed to chapters focused on static/dynamic analysis tooling). The chapter is organized from language-level bug classes to environment-specific gotchas across Linux, Windows, and sandboxing. It also teases an upcoming Claude skill that will transform checklist items into platform- a...

🔧 Technical Details

  1. Static-buffer libc return value pitfall (allowlist bypass): Some libc APIs (e.g., inet_ntoa()) return pointers to static internal storage. If code calls the function twice and stores both pointers (e.g., resolving a user-provided IP and an allowlisted IP) and then compares them with strcmp, the second call may overwrite the buffer, causing both pointers to reference the same final string. This can collapse an allowlist check and let disallowed values pass.

    2) Shell command execution from validated-but-reused input: Even if an input string is “validated” with a parser (e.g., inet_aton), reusing the original raw string to build a shell command and invoking system() creates a command-injection/RCE primitive because a shell interprets metacharacters. Safer patterns are to avoid shelling out or to use non-shell process creation with an argv array.

    3) Kernel/driver control-flow influenced ...

🤖 Agent Actions

I’m mapping the repo first and then I’ll read the most relevant existing pages before deciding where a single update belongs. After that I’ll verify whether the blog adds genuinely new material or just repeats content already present.
The repo already has a likely anchor page for source-review material, but I need to confirm whether the concrete gotchas from the blog are already documented elsewhere. I’m reading the review page plus Windows and command-injection candidates now to avoid duplicating existing content.
I’ve confirmed the main concrete additions are not already documented: inet_ntoa() static-buffer misuse, validated-but-reused input reaching system(), and driver code that trusts attacker-chosen registry paths for control-flow decisions. I’m reading one more adjacent page plus the target file’s tail so I can patch a single page cleanly and keep references at the end.
I’ve got the placement decision. Next I’m validating the source material and the handbook chapter itself so the added checklist points stay tight and technically defensible instead of turning into a vague summary of the blog.
I’m editing code-review-tools.md now. The patch will keep everything in one file and add a short C/C++ manual-review subsection with concrete bug patterns, small examples, and references at the end.
Updated code-review-tools.md with a new C/C++ Manual Review Gotchas section.

The added content abstracts the technical value from the blog into reusable review guidance instead of documenting the blog post itself: inet_ntoa() static-buffer allowlist bypasses, validated-but-raw input later reaching system(), Windows driver patterns where attacker-chosen registry paths influence privileged control flow, and Windows path-handling review checks including unquoted CreateProcess* paths and WorstFit-style ANSI/Wide-char issues. I also added a final ## References section with the blog, the handbook chapter, and the WorstFit article.

Verified the diff and kept the change to a single file. No tests were needed for this markdown-only update.


This PR was automatically created by the HackTricks Feed Bot. Please review the changes carefully before merging.

@carlospolop
Copy link
Copy Markdown
Collaborator Author

🔗 Additional Context

Original Blog Post: https://blog.trailofbits.com/2026/04/09/master-c-and-c-with-our-new-testing-handbook-chapter/

Content Categories: Based on the analysis, this content was categorized under "Generic Methodologies & Resources -> Source code Review / SAST Tools (or create/add under a Secure Code Review subsection for C/C++ gotchas); additionally cross-link from Pentesting Web -> Command Injection (system()/shelling-out pitfalls) and Windows Local Privilege Escalation/Windows security notes for CreateProcess unquoted path & WorstFit path issues".

Repository Maintenance:

  • MD Files Formatting: 972 files processed

Review Notes:

  • This content was automatically processed and may require human review for accuracy
  • Check that the placement within the repository structure is appropriate
  • Verify that all technical details are correct and up-to-date
  • All .md files have been checked for proper formatting (headers, includes, etc.)

Bot Version: HackTricks News Bot v1.0

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