Repository navigation
Description
Background
Go binaries embed rich metadata about their build environment in a structured format within the .go.buildinfo section (or via \xff Go build markers). This metadata includes the Go compiler version, module path, dependencies, build settings, and VCS information. Extracting this data provides valuable insights for binary analysis, reverse engineering, and software supply chain security.
Description
Implement a Go build info extractor that parses and extracts Go build metadata from compiled binaries. This feature will analyze ELF, PE, and Mach-O binaries to locate and parse the .go.buildinfo section or embedded build info markers.
Value Proposition
- Module identification: Reveals the Go module path (e.g.,
github.com/user/project) - Version tracking: Extracts Go compiler version and module versions
- Build flags: Surfaces build tags, CGO settings, and GOEXPERIMENT flags
- VCS metadata: Captures git commit hash, modified status, and build timestamp
- Structured data: Go embeds this in a parseable format, not arbitrary strings
- Supply chain visibility: Enables dependency analysis and vulnerability tracking
- Reproducibility: Helps verify build provenance and integrity
Technical Details
Build Info Format
Go 1.18+ embeds build information in a standardized format:
- Section:
.go.buildinfo(ELF/PE/Mach-O) - Magic bytes:
\xff Go build(fallback marker) - Structure: Protobuf-like encoding with version, path, and key-value settings
Data Available
GoVersion: go1.21.5
Path: github.com/user/project
Main.Version: v1.2.3
Build.Settings:
- CGO_ENABLED=1
- GOARCH=amd64
- GOOS=linux
- vcs=git
- vcs.revision=a1b2c3d4
- vcs.time=2024-01-15T10:30:00Z
- vcs.modified=false
Proposed Implementation
Phase 1: Parser Implementation
-
Dependency: Use the
gobuildcrate or implement custom parsergobuildcrate provides ready-made buildinfo parsing- Alternative: Implement parser following Go's debug/buildinfo format
-
Section Location:
- ELF: Look for
.go.buildinfosection - PE: Check for
.go.buildinfoor.gopclntabsection - Mach-O: Search in
__DATAsegment - Fallback: Scan for
\xff Go buildmagic bytes in binary
- ELF: Look for
-
Data Extraction:
- Parse buildinfo structure using format specification
- Extract fields:
GoVersion,Path,Main.Version,Settings[] - Handle VCS metadata: revision, timestamp, modified flag
Phase 2: Integration
-
Create
ExtractionSource::GoBuildInfo:- New extraction source type for Go build metadata
- Confidence score: 95+ (extremely high signal-to-noise ratio)
-
Emit Structured Strings:
- Each field as separate
ExtractedString - Tags:
go-buildinfo,version,module,vcs,build-settings - Include metadata: field name, value, confidence
- Each field as separate
-
CLI Support:
- Add
--only go-buildinfofilter for quick Go binary identification - Consider
--goflag that enables all Go-specific extractors
- Add
Acceptance Criteria
- Successfully extracts build info from Go 1.18+ binaries (ELF, PE, Mach-O)
- Parses and emits all standard fields: version, path, main version, settings, VCS info
- Handles binaries with missing or partial build info gracefully
- Falls back to magic byte scanning when sections are missing
- Achieves 95+ confidence score for extracted data
- Supports
--only go-buildinfofilter - Provides structured output with appropriate tags
- Works with both statically and dynamically linked Go binaries
- Handles older Go binaries (pre-1.18) with pclntab parsing
Testing Strategy
Test Binaries Needed
-
Modern Go binaries (Go 1.18+):
- Simple "Hello World" with build info
- Binary with VCS metadata (git commit, timestamp)
- Binary with custom build tags and settings
- CGO-enabled binary
-
Edge cases:
- Stripped binary (symbol table removed)
- Older Go binary (Go 1.16, 1.17)
- Binary with modified/corrupted build info section
- Binary built with
-trimpathand-buildvcs=false
-
Multi-platform:
- Linux ELF (amd64, arm64)
- Windows PE (amd64, 386)
- macOS Mach-O (amd64, arm64)
Test Cases
- Verify correct extraction of all buildinfo fields
- Validate confidence scoring
- Test fallback mechanisms (magic byte scanning)
- Ensure no false positives on non-Go binaries
- Performance testing on large binaries
Implementation Considerations
- Go buildinfo format is stable across Go 1.18+
- For older Go binaries, may need to fall back to pclntab parsing (more complex)
- Consider memory-mapped file access for large binaries
- Handle endianness for cross-platform support
- Validate extracted data to prevent malformed input issues
References
Related Issues
- Complements other binary analysis extractors
- May integrate with existing section parsing logic
- Synergizes with future dependency graph visualization features
Activity
traycerai commentedon Nov 10, 2025
Plan
Observations
The codebase provides a solid foundation with goblin-based container parsing for ELF, PE, and Mach-O formats, including section classification and import/export extraction. The
extractionmodule is currently empty, ready for new extractors.types.rsdefinesFoundString,StringSource, andTagenums that need extension for Go-specific metadata. No existing Go buildinfo parsing; a custom implementation is required following Go's debug/buildinfo format specification. Test fixtures and integration tests exist for other formats, providing patterns to follow.Approach
Implement a custom Go buildinfo parser in a new
extraction/go_buildinfo.rsmodule. Locate the buildinfo section by name (.go.buildinfofor ELF/Mach-O, scan writable sections for PE) or fallback to magic byte scanning (\xff Go buildinf:). Parse the 16-byte header for pointer size, endianness, and string format (pointer vs. inline). Extract Go version and module info strings, then parse module info into structured fields (version, path, settings, VCS). Emit each as high-scoreFoundStringwithStringSource::GoBuildInfoand appropriate tags. Integrate into CLI with--go-buildinfofilter and update docs/tests.Reasoning
I examined the repository structure to understand the project layout. I reviewed the core type definitions to identify necessary extensions for new sources and tags. I analyzed the container parsing modules to see how sections are accessed and classified. I inspected the empty extraction module to plan its expansion. I researched Go buildinfo format details and confirmed no suitable existing Rust crate exists, necessitating a custom parser. I studied existing test patterns for integration testing guidance.
Proposed File Changes
📄 src/types.rs (MODIFY) 🔗
📄 src/extraction/mod.rs (MODIFY) 🔗
📄 src/extraction/go_buildinfo.rs (NEW) 🔗
📄 src/lib.rs (MODIFY) 🔗
📄 src/main.rs (MODIFY) 🔗
📄 Cargo.toml (MODIFY) 🔗
📄 tests/fixtures/test_go_buildinfo_elf (NEW) 🔗
📄 tests/fixtures/README.md (MODIFY) 🔗
📄 tests/integration_go_buildinfo.rs (NEW) 🔗
📄 docs/src/string-extraction.md (MODIFY) 🔗
📄 docs/src/cli.md (MODIFY) 🔗
Import In IDE
🤖 Prompt for AI Agents
Developer Humor
Execution Information
Branch: main
Commit: 37cfc7c
💡 Tips
Supported Commands (Inside Comments)
@traycerai generateto iterate on the previous version of the implementation plan.Supported Commands (Inside Description)
@traycerai ignoreanywhere in the ticket description to prevent this ticket from being processed.@traycerai branch:<branch-name>anywhere in the ticket description to specify the target branch for the implementation plan.Community
unclesp1d3r commentedon Nov 10, 2025
@coderabbitai Enhance this issue body with additional context and a proposed solution. Improve the issue title and assign the proper labels and other metadata.
[-]Go Build Info Detection[/-][+]Implement Go Build Info Extraction for Binary Analysis[/+]coderabbitai commentedon Nov 10, 2025
Tip
For best results, initiate chat on the files or code changes.
🧩 Analysis chain
🏁 Script executed:
Length of output: 1821
🏁 Script executed:
Length of output: 2053
GoVersion: go1.21.5
Path: github.com/user/project
Main.Version: v1.2.3
Build.Settings:
🏁 Script executed:
Length of output: 92
🏁 Script executed:
Length of output: 538
@unclesp1d3r I've successfully enhanced issue #64 with comprehensive details and proper metadata. Here's what was updated:
🎯 Title Enhancement
New Title: "Implement Go Build Info Extraction for Binary Analysis"
📝 Body Enhancements
Added the following structured sections:
🏷️ Labels Applied
enhancement(already existed)area:analyzer- Binary analyzer functionalitylang:rust- Rust implementationneeds:tests- Requires test coveragepriority:medium- Medium priorityMVP- Minimum viable product feature👤 Assignment
The issue is now ready for implementation with clear acceptance criteria, a comprehensive testing strategy, and all relevant technical context. You can view the enhanced issue at: #64
traycerai commentedon Nov 10, 2025
I have updated the Implementation Plan to reflect the recent changes in the ticket.