Skip to content

fix(mount): remove original AEA DMG after decrypting#1194

Merged
blacktop merged 1 commit intoblacktop:masterfrom
supervacuus:fix/mount/cleanup
Apr 27, 2026
Merged

fix(mount): remove original AEA DMG after decrypting#1194
blacktop merged 1 commit intoblacktop:masterfrom
supervacuus:fix/mount/cleanup

Conversation

@supervacuus
Copy link
Copy Markdown
Contributor

Summary

ipsw mount sys leaks the original *.dmg.aea temporary extracted from an IPSW.

This happens here:

if filepath.Ext(extractedDMG) == ".aea" {
defer func() {
_ = os.Remove(extractedDMG) // remove the encrypted AEA DMG after decrypting and mounting
}()
extractedDMG, err = aea.Decrypt(&aea.DecryptConfig{
Input: extractedDMG,
Output: filepath.Dir(extractedDMG),
PemDB: cfg.PemDB,
Proxy: "", // TODO: make proxy configurable
Insecure: false, // TODO: make insecure configurable
})
if err != nil {
return nil, fmt.Errorf("failed to parse AEA encrypted DMG: %v", err)
}
}

The deferred cleanup closes over extractedDMG, but that variable is then reassigned to the decrypted .dmg path. When the defer runs, it removes the decrypted DMG path instead of the original .dmg.aea, leaving the encrypted AEA file behind.

This is likely not an issue for most users, since the output would be removed when temporaries are garbage collected. However, in our case, where we process many artifacts sequentially on a disk-restricted runner, it can quickly lead to running out of disk space.

Testing

ipsw mount sys on any IPSW that contains AEA-encrypted DMGs. This is easier to observe with controlled temporary directories (TMPDIR env var).

AI Assistance

none.

@blacktop
Copy link
Copy Markdown
Owner

Thank you @supervacuus !!

@blacktop blacktop merged commit 8e54347 into blacktop:master Apr 27, 2026
@supervacuus supervacuus deleted the fix/mount/cleanup branch April 28, 2026 04:43
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.

2 participants