Repository navigation
feat(agent): encrypt the token with DPAPI on Windows (#1) - #240
Open
Stephanya Casanova (savacano28) wants to merge 3 commits into
Open
Stephanya Casanova (savacano28) wants to merge 3 commits into
Stephanya Casanova (savacano28) wants to merge 3 commits into
Conversation
Stephanya Casanova (savacano28)
changed the base branch from
main
to
sca/agent-secret-store
October 12, 2026 13:47
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## sca/secret-store-with-import #240 +/- ##
=============================================================
Coverage 49.95% 49.95%
=============================================================
Files 16 16
Lines 1011 1011
=============================================================
Hits 505 505
Misses 506 506
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
5 of 6 tasks
Stephanya Casanova (savacano28)
changed the base branch from
sca/agent-secret-store
to
sca/secret-store-with-import
October 18, 2026 15:51
Stephanya Casanova (savacano28)
force-pushed
the
sca/windows-dpapi-token
branch
from
October 18, 2026 17:35
c25f1b1 to
f554785
Compare
4 of 6 tasks
Stephanya Casanova (savacano28)
marked this pull request as ready for review
October 19, 2026 07:12
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
Security-sensitive DPAPI migration and file permissions require human validation across all three Windows installation modes.
No open issues 🎉
What changed in this PR
Adds Windows DPAPI token encryption using the secret-store migration flow introduced in #245.
Changes:
- Enables account-scoped DPAPI storage on Windows.
- Updates all three Windows installers to create restricted bootstrap and encrypted-token files instead of storing tokens in config.
- Adds tests for encryption, tampering, in-place writes, and bootstrap migration.
| File | Description |
|---|---|
src/tests/secrets/mod.rs |
Registers DPAPI tests. |
src/tests/secrets/dpapi_tests.rs |
Tests DPAPI storage and migration. |
src/secrets/mod.rs |
Enables the Windows secret store. |
src/secrets/dpapi.rs |
Implements account-scoped encryption and storage. |
installer/windows/agent-installer.nsi |
Creates restricted token files for SYSTEM. |
installer/windows/agent-installer-session-user.nsi |
Creates token files accessible to the session user. |
installer/windows/agent-installer-service-user.nsi |
Grants service-account access to token files. |
Cargo.toml |
Enables required Windows API features. |
Review effort: Balanced
Stephanya Casanova (savacano28)
force-pushed
the
sca/windows-dpapi-token
branch
6 times, most recently
from
October 19, 2026 13:47
edda1ff to
ef6f801
Compare
Stephanya Casanova (savacano28)
force-pushed
the
sca/windows-dpapi-token
branch
3 times, most recently
from
October 19, 2026 15:48
0c68a02 to
5fb23f2
Compare
Stephanya Casanova (savacano28)
force-pushed
the
sca/windows-dpapi-token
branch
4 times, most recently
from
October 20, 2026 13:11
5d08817 to
ad266c3
Compare
Stephanya Casanova (savacano28)
force-pushed
the
sca/windows-dpapi-token
branch
from
October 27, 2026 15:25
ad266c3 to
f960448
Compare
Stephanya Casanova (savacano28)
force-pushed
the
sca/windows-dpapi-token
branch
from
October 29, 2026 14:12
f960448 to
79a76f6
Compare
damgouj (damgouj)
approved these changes
Oct 29, 2026
damgouj (damgouj)
left a comment
Member
There was a problem hiding this comment.
I will test but code seems OK to me. 1 question and 1 remark:
- is the performance still the same because it gets each time the token from the secret store?
- the agent size is now 200ko bigger, be careful if we do this for the implant because it's downloaded for each attack.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
Plugs a Windows DPAPI store into #245. Only active with
[secrets]/os_store = true. Off by default: nothing changes for users (same as #239).DpapiStore: the token is encrypted with DPAPI (user scope) inopenaev-agent-token.dpapi, next to the exe. Only the account the agent runs as can decrypt it (SYSTEM for the service)..dpapi, reads it back, then removes thetokenline from the config..dpapiwith a restricted ACL: SYSTEM, Administrators and its own account, not inherited.main)..dpapi.dpapi.dpapiTesting
Windows VM, PowerShell as Administrator, one clean VM per mode (service, service-user, session-user).
cargo build --release --locked, thenmakensisoninstaller/windows/*.nsi(or the CI artifacts). Pin the agent version on the platform (executor.openaev-agent.binaries.version).main. Same asmain: token in the config, no.dpapi, agent online,whoamiinject OK.Token moved to the OS secret store;.dpapinot empty, ACL without(I); notokenline in the config; online.Token movedline..dpapi).[Security.Cryptography.ProtectedData]::Unprotect([IO.File]::ReadAllBytes("<dpapi>"), $null, 'CurrentUser')fails withKey not valid. Searching the token in the log and the install folder returns nothing..dpapiincluded.Full step-by-step plan: Notion "Manual tests: DPAPI (FF)".
Related issues
Checklist
Further comments
Generated with Claude Code