m4b / m4b/goblin

Validating authenticode of PE File

Open
#416 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
1.5k
Forks
202
PR merge metrics
No merged PRs in 30d

Description

Hi, I am trying to validate the authenticode of PE files by computing a hash from the PE file using goblin and then comparing against the authenticode signature in the PKCS7 SignedData.

It's working well for most exe files and the value matches. However, when I am testing it for firefox.exe, the computed value does not match the signature and I am wondering what is the issue.

This is the code I used to compute the authenticode, is there anything I am missing?

```
let mut xhasher = Hasher::new(MessageDigest::sha256()).unwrap();
let authenticate_data = pe.authenticode_ranges();
for a in authenticode_data.into_iter() {
xhasher.update(a);
}
let final_hash = xhasher.finish().unwrap();
println!("hash {:?}", hex::encode(final_hash));
```

The authenticode I computed : ee2d315da52ae04011dca0f89bba6801f81454f437463675b4285742d720076d
The actual authenticode : d60710b5d82808bd887e1d8f8cda866ce22eee173adb407b48e2c001456aeff3 (definitely correct, verified using other sources)

firefox.exe : https://www.mozilla.org/en-US/firefox/windows/

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing goblin's PE authenticode_ranges implementation and compare the ranges it returns with Firefox's authenticode and PKCS7 SignedData. Reproduce the SHA-256 calculation against the linked firefox.exe, then determine why the computed and verified values differ. Done means explaining the mismatch or identifying a confirmed parser defect and its regression coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cryptography, reverse-engineering, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.