Skip to content

Conversation

@Alan-Jowett
Copy link
Member

@Alan-Jowett Alan-Jowett commented Oct 29, 2025

Description

Document the proposal for providing a SHA256 hash of the ELF file used to generate a PE image (dll or sys file).

Testing

N/A

Documentation

Yes

Installation

No

Issue Link

Related to #4758.

@dthaler
Copy link
Collaborator

dthaler commented Oct 31, 2025

The "ensure-issue-linked" check on this PR tried to post a comment complaining that the PR description does not reference an issue. However, commenting failed due to #4726 (which is fixed in pending PR #4762).

Alan-Jowett pushed a commit to Alan-Jowett/ebpf-for-windows that referenced this pull request Jan 5, 2026
- Fix netsh command syntax to use optional tags: [filename=]<path>
- Clarify ELF hash embedding context - only present if compiled with hash embedding
- Fix size discrepancy: 64 bytes for SHA256 hex representation (not 32)
- Fix bash code blocks to PowerShell (Get-FileHash is PowerShell, not bash)
- Remove implementation details section as requested by reviewer
@Alan-Jowett Alan-Jowett requested a review from Copilot January 7, 2026 16:46
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a proposal document that describes a new feature for embedding SHA-256 hashes of ELF files into generated PE images during eBPF compilation. The proposal aims to provide traceability and integrity verification capabilities for the eBPF for Windows ecosystem.

Key Changes

  • Comprehensive proposal document covering hash embedding in PE images, a new API for hash extraction, and a NetSh command-line interface
  • Documentation includes technical implementation details, use cases, testing strategy, and security considerations
  • Provides examples of command usage and expected outputs for hash verification workflows

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Alan Jowett and others added 3 commits January 7, 2026 09:37
Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>
- Fix netsh command syntax to use optional tags: [filename=]<path>
- Clarify ELF hash embedding context - only present if compiled with hash embedding
- Fix size discrepancy: 64 bytes for SHA256 hex representation (not 32)
- Fix bash code blocks to PowerShell (Get-FileHash is PowerShell, not bash)
- Remove implementation details section as requested by reviewer
Signed-off-by: GitHub Copilot <copilot@github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

**Technical Implementation:**
```cpp
#pragma const_seg(push, "hash")
const uint8_t _elf_hash[] = { /* hash bytes */ };
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code example shows hash bytes as "/* hash bytes */" which is a placeholder comment, but the example output in lines 70-72 shows the hash formatted with spaces grouping bytes. Consider clarifying in the Technical Implementation section whether the actual generated code will include the full 32-byte array literal (e.g., "0xa1, 0xb2, 0xc3, ...") or if this is intentionally left as a placeholder for the documentation.

Suggested change
const uint8_t _elf_hash[] = { /* hash bytes */ };
// bpf2c generates a full 32-byte SHA-256 array here; the values below are an example.
const uint8_t _elf_hash[] = {
0xa1, 0xb2, 0xc3, 0xd4, 0xe5, 0xf6, 0x07, 0x18,
0x29, 0x3a, 0x4b, 0x5c, 0x6d, 0x7e, 0x8f, 0x90,
0x01, 0x12, 0x23, 0x34, 0x45, 0x56, 0x67, 0x78,
0x89, 0x9a, 0xab, 0xbc, 0xcd, 0xde, 0xef, 0xf0,
};

Copilot uses AI. Check for mistakes.
Comment on lines +67 to +77
Without `hashonly` flag:
```
Hash for example.sys:
Size: 32 bytes
Data: a1b2c3d4e5f6789a bcdef012345678ab cdef0123456789ab cdef0123456789ab
```

With `hashonly` flag:
```
A1B2C3D4E5F6789ABCDEF012345678ABCDEF0123456789ABCDEF0123456789AB
```
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example output shows inconsistent hash formatting between the two examples. In the "Without hashonly flag" example (lines 70-72), the hash is shown in lowercase with spaces separating groups of bytes. In the "With hashonly flag" example (line 76), it's shown in uppercase without spaces. While this might reflect the actual output format, it would be helpful to explicitly document this formatting difference or ensure the byte representation in line 71 accurately reflects what the actual command outputs (the hash appears to be split into 4 groups of 8 bytes each, which totals to 32 bytes as stated).

Copilot uses AI. Check for mistakes.

**Parameters:**
- `filename`: Required path to the PE file
- `hashonly`: Optional flag to output only the hash value (compatible with PowerShell Get-FileHash format)
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameter description for "hashonly" states it's "compatible with PowerShell Get-FileHash format", but the example shows the hash output in uppercase without any PowerShell property formatting (like "Algorithm : SHA256" or "Hash : ..."). While the hash value itself matches Get-FileHash's format, clarifying that only the hash value is compatible (not the full output format) would make this more precise.

Suggested change
- `hashonly`: Optional flag to output only the hash value (compatible with PowerShell Get-FileHash format)
- `hashonly`: Optional flag to output only the hash value as a hexadecimal string (compatible with the `Hash` value from PowerShell `Get-FileHash`, but not its full formatted output)

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants