Repository navigation
Description
Overview
Extract meaningful strings and metadata from DWARF debug sections present in non-stripped binaries. DWARF debug information contains high-confidence, developer-chosen identifiers that provide significant value for binary analysis even when traditional symbols are unavailable.
Background: What is DWARF?
DWARF (Debugging With Attributed Record Formats) is a standardized debugging data format used by compilers to embed source-level information into binaries. It's the dominant debug format for ELF (Linux/Unix) and Mach-O (macOS) binaries compiled with -g flags.
Key DWARF Sections
.debug_info: Core debugging data containing DIEs (Debug Information Entries) with function/variable names, types, and source locations.debug_str: String table containing all text references from.debug_info.debug_line: Line number program mapping machine instructions to source file paths and line numbers.debug_abbrev: Abbreviation declarations describing DIE structure (needed for parsing.debug_info).debug_types(DWARF 4),.debug_str_offsets(DWARF 5): Additional optimization sections
Value Proposition
High-Confidence Identifiers
DWARF data is structured and intentional—not arbitrary byte patterns. Extracting from DWARF provides:
- Function names:
handle_authentication,decrypt_payload,validate_license - Variable names:
secret_key,api_endpoint,config_path - Type information:
struct UserCredentials,class DatabaseConnection - Source file paths:
/home/builder/project/src/crypto/aes.c, revealing project structure
Intelligence Value
- Build environment disclosure: Absolute paths expose developer machines, CI systems, directory structures
- Code organization: Source file names reveal architectural patterns and module boundaries
- Semantic context: Variable/function names provide intent rather than raw string literals
- Reverse engineering: Symbolic names dramatically accelerate understanding compiled code
Complementary to Existing Extraction
DWARF augments rather than replaces existing string extraction:
- Symbols: DWARF works when
.symtabis stripped but debug sections remain - Section data: DWARF names often don't appear in
.rodata(they're in.debug_str) - Imports/exports: DWARF reveals internal implementation details, not just API boundaries
Proposed Implementation
1. Add gimli Dependency
[dependencies]
gimli = "0.29"
object = "0.36" # Provides DWARF section reader interfaceRationale: gimli is the de-facto Rust DWARF parser, maintained by the Rust debugging tools team and used by addr2line, cargo, and debuggers.
2. Extend Existing Types
In src/types.rs:
StringSource::DebugInfoalready exists ✅- Add new
Tagvariants:pub enum Tag { // ... existing tags DwarfSymbol, // Function/variable name from DW_AT_name DwarfFilePath, // Source file path from DW_AT_comp_dir / DW_AT_decl_file DwarfType, // Type name from DW_TAG_structure_type, DW_TAG_class_type }
3. Create DWARF Extraction Module
New file: src/extraction/dwarf.rs
use gimli::{Dwarf, EndianSlice, RunTimeEndian};
use object::{Object, ObjectSection};
pub struct DwarfExtractor {
skip_dwarf: bool,
max_section_size: Option<usize>,
}
impl DwarfExtractor {
pub fn extract(&self, data: &[u8], format: BinaryFormat) -> Result<Vec<FoundString>> {
// 1. Load DWARF sections using object crate
// 2. Parse with gimli::Dwarf
// 3. Iterate compilation units
// 4. Extract DW_AT_name, DW_AT_comp_dir, DW_AT_decl_file
// 5. Return FoundString with high scores (90+)
}
}4. Integration Points
In src/container/elf.rs:
- Classify DWARF sections correctly (already done:
SectionType::Debugfor.debug_*✅) - Ensure DWARF sections are included in
ContainerInfo
In src/extraction/mod.rs:
- Import and instantiate
DwarfExtractor - Call after section-based extraction
- Coordinate with deduplication logic
5. CLI Integration
In src/main.rs (when CLI is implemented):
#[derive(Parser)]
struct Args {
// ... existing args
/// Skip DWARF debug section extraction (faster for large binaries)
#[arg(long)]
skip_dwarf: bool,
/// Maximum DWARF section size to process (in MB)
#[arg(long, default_value = "100")]
max_dwarf_size: usize,
}Technical Considerations
Performance
- DWARF parsing is CPU-intensive: A single
.debug_infosection can be 50-200MB in optimized Rust binaries with full debug info - Mitigation strategies:
--skip-dwarfflag for performance-critical scenarios- Size limits (
--max-dwarf-size) to skip enormous sections - Lazy parsing: only process compilation units, skip full type graphs
- Skip
.debug_typesinitially (less string content, high complexity)
Binary Size Realities
- Stripped binaries (
strip --strip-debug): No DWARF sections → graceful no-op - Partially stripped (
strip --strip-unneeded): May retain DWARF → full extraction - Debug builds: Massive DWARF sections (10-100x code size) → sampling or limits needed
Scoring Strategy
Assign high scores since DWARF strings are definitionally meaningful:
- Function/variable names (
DW_AT_name): Score 95 - Source file paths (
DW_AT_comp_dir,DW_AT_decl_file): Score 90 - Type names (
DW_TAG_structure_type): Score 92
These should rank above most .rodata strings but below critical items like hardcoded URLs/keys.
Deduplication
-
Problem: A string like
parse_configmay appear in:.debug_str(DWARF).symtab(symbol table).dynstr(dynamic symbols).rodata(error messages mentioning the function)
-
Solution: Deduplication by
(text, encoding)tuple in final output, preserving highest score and all relevant tags.
Security & Privacy
- Build path disclosure: DWARF exposes absolute paths like
/home/alice/secret-project/src/- This is intentional for binary analysis—users examining untrusted binaries want this intel
- Document in output that DWARF reveals build environment details
Implementation Checklist
- Add
gimliandobjectdependencies toCargo.toml - Create
src/extraction/dwarf.rsmodule - Add
DwarfSymbol,DwarfFilePath,DwarfTypetags toTagenum - Implement
DwarfExtractor::extract()method- Load DWARF sections from ELF/Mach-O
- Parse
.debug_infocompilation units - Extract
DW_AT_nameattributes →FoundStringwithTag::DwarfSymbol - Extract
DW_AT_comp_dir/DW_AT_decl_file→Tag::DwarfFilePath - Extract structure/class type names →
Tag::DwarfType
- Add
--skip-dwarfand--max-dwarf-sizeCLI flags - Integrate into main extraction pipeline
- Add deduplication logic for DWARF + symbol table overlap
- Write unit tests with small DWARF samples
- Write integration tests:
- Test with stripped binary (no DWARF)
- Test with debug build (full DWARF)
- Test with large DWARF section (size limits)
- Document DWARF extraction in README and
--help
Testing Strategy
Unit Tests
- Mock DWARF sections with known DIEs
- Verify extraction of specific
DW_AT_namevalues - Test score assignment logic
Integration Tests
Create test fixtures:
tests/fixtures/hello_debug: Minimal C program compiled with-gtests/fixtures/hello_stripped: Same binary withstrip --strip-debugtests/fixtures/rust_debug: Rust binary with full debug info (tests demangling + DWARF)
Expected behavior:
hello_debug: Extract function names (main,printf), source pathhello_stripped: Gracefully skip, no errorsrust_debug: Extract Rust function names, handle DWARF 4/5 versions
References
- DWARF 5 Standard
gimlicrate documentation- DWARF sections overview
- Practical Binary Analysis (Chapter 6: Symbolic Execution) - discusses DWARF usage in reverse engineering
Success Criteria
- ✅ Extract all
DW_AT_nameattributes from.debug_info - ✅ Extract source file paths from line number programs
- ✅ Handle DWARF versions 2-5 gracefully
- ✅
--skip-dwarfflag works correctly - ✅ No crashes on malformed DWARF (handle
gimliparse errors) - ✅ Deduplication prevents duplicate strings from DWARF + symtab
- ✅ Documentation includes DWARF extraction examples
Activity
traycerai commentedon Nov 10, 2025
Plan
Observations
The codebase features a modular architecture with established container parsing for ELF, PE, and Mach-O formats using the
goblincrate. Thetypes.rsmodule includesStringSource::DebugInfoandSectionType::Debug, facilitating DWARF integration. Extraction and classification modules are placeholders awaiting implementation. The ELF parser correctly identifies DWARF sections like.debug_infoand.debug_str. CLI structure inmain.rssupports extensible argument parsing. Documentation and test fixtures exist but lack DWARF-specific content. The project follows Rust best practices with Cargo dependencies and integration testing patterns.Approach
Implement DWARF string extraction by adding
gimliandobjectdependencies for parsing. Create adwarf.rsmodule to load DWARF sections, traverse DIEs in compilation units, and extract high-value strings fromDW_AT_name,DW_AT_comp_dir, andDW_AT_decl_fileattributes. Extend theTagenum withDwarfSymbol,DwarfFilePath, andDwarfTypevariants. Integrate into the extraction pipeline with configurable skipping via CLI flags. Assign scores of 90-95 to DWARF strings based on their structured nature. Add unit and integration tests using debug-compiled fixtures, and update documentation to cover the new feature.Reasoning
Examined the repository structure and key files including Cargo.toml, types.rs, extraction mod, container parsers, main.rs, and documentation. Reviewed existing section classification logic in ELF parser to confirm DWARF section handling. Studied the proposed implementation in the ticket for gimli usage patterns, attribute extraction, and scoring strategy. Analyzed test fixtures and integration test patterns to plan appropriate testing coverage. Consulted gimli documentation examples for DIE traversal and string resolution techniques.
Proposed File Changes
📄 Cargo.toml (MODIFY) 🔗
📄 src/types.rs (MODIFY) 🔗
📄 src/extraction/mod.rs (MODIFY) 🔗
📄 src/extraction/dwarf.rs (NEW) 🔗
📄 src/main.rs (MODIFY) 🔗
📄 src/lib.rs (MODIFY) 🔗
📄 tests/integration_dwarf.rs (NEW) 🔗
📄 README.md (MODIFY) 🔗
📄 docs/src/string-extraction.md (MODIFY) 🔗
📄 .kiro/specs/stringy-binary-analyzer/tasks.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.
[-]DWARF Debug Information Extraction[/-][+]Extract strings from DWARF debug information (.debug_info, .debug_str, .debug_line)[/+]coderabbitai commentedon Nov 10, 2025
Tip
For best results, initiate chat on the files or code changes.
🧩 Analysis chain
🏁 Script executed:
Length of output: 1705
🏁 Script executed:
Length of output: 277
🏁 Script executed:
Length of output: 26
🏁 Script executed:
Length of output: 26
🏁 Script executed:
Length of output: 385
🏁 Script executed:
Length of output: 26
🏁 Script executed:
Length of output: 530
🏁 Script executed:
Length of output: 7196
🏁 Script executed:
Length of output: 5122
🏁 Script executed:
Length of output: 26
🏁 Script executed:
Length of output: 2262
🏁 Script executed:
Length of output: 23307
🏁 Script executed:
Length of output: 30
🏁 Script executed:
Length of output: 1939
🏁 Script executed:
Length of output: 1519
🏁 Script executed:
Length of output: 61
@unclesp1d3r I've successfully enhanced issue #62 with comprehensive context and implementation details. Here's what was improved:
🎯 Enhanced Title
Before: "DWARF Debug Information Extraction"
After: "Extract strings from DWARF debug information (.debug_info, .debug_str, .debug_line)"
The new title is more specific and immediately tells developers which sections are involved.
📋 Major Content Additions
1. Background Section
2. Detailed Value Proposition
3. Concrete Implementation Plan
gimli = "0.29",object = "0.36")DwarfExtractorstructTagvariants:DwarfSymbol,DwarfFilePath,DwarfType4. Technical Considerations
--skip-dwarfflag and size limits5. Implementation Checklist
Complete 13-step checklist covering dependencies, module creation, integration, testing, and documentation.
6. Testing Strategy
Specific test fixtures with expected behaviors:
hello_debug(with DWARF)hello_stripped(graceful handling)rust_debug(DWARF 4/5 + demangling)7. References
Links to DWARF standard,
gimlidocs, and relevant technical resources.🏷️ Metadata & Labels Applied
area:analyzer- Binary analyzer functionalityMVP- Critical for minimum viable productpriority:medium- Important but not blockingneeds:tests- Requires comprehensive test coverageepic- Large feature spanning multiple tasks🔑 Key Architecture Insights
The enhanced issue leverages existing codebase strengths:
StringSource::DebugInfoalready exists intypes.rs.debug_*sections asSectionType::DebugContainerParserdesign makes integration straightforwardThe issue is now ready for implementation with clear technical direction, measurable success criteria, and proper prioritization within your project roadmap.
traycerai commentedon Nov 10, 2025
I have updated the Implementation Plan to reflect the recent changes in the ticket.