straight-sundown-84319
10/21/2025, 9:25 PMstate.py doesn't save any secrets
Not even the LLM api key. The _secrets_manager is private and so will not be saved either.
event_service.py is used by the agent server and saves secrets.
When using the agent server on its own (No App Server)
This means that secrets are stored in plain text on the host machine. This is similar to V0 OSS where secrets are stored in plain text inside secrets.json. It is not secure, but even if we encrypted these values at rest it would mean we would also need to store the encryption key somewhere unencrypted - either that or we disable persistence unless the user has set up a master key in their environment and warn them of this - but usability and security are pulling in opposite directions
When using the App Server...
We attempt to reduce the scope of these threats by:
• Secrets are stored in the database, not any file system connected to the app server. (In non single user environments this database is typically Postgres on a separate machine)
• All Secrets stored in the database are encrypted at rest using a master key stored in the app server (Typically defined as an environment variable - this is the same as V0 SAAS except we settled on JWKS as the standard to make key rotation easier.)
• Secrets passed to Agent Servers are typically instances of LookupSecret - they include a URL where the actual secret is available and a key which expires after 2 weeks (Configurable as an environment variable) - So the actual secrets are not persisted within the sandbox, nor are they available as environment variables. If there is ever a detected leak, historical secrets are safer.
Threat Analysis...
• When installed on a single user machine app server / agent server, if a malicious user gained read access to the host file system, they could read any persisted keys. (Or read the master key and use that to decrypt any keys.)
• When using the app server, if a malicious user gained read access to the container file system they could read the git token for the selected repository only, and the user secrets - assuming they gained access to a conversation which is less than 2 weeks old.
• When using the app server with a database on a separate machine, if a malicious user got access to a database dump they would also need to get the master key from the app server in order to decrypt the secrets.calm-artist-7206
10/21/2025, 10:34 PMmeta.json too, I think; the user just needs to use the server otherwise I don’t think we save it
◦ we need to store one copy and/or read it, it’s no different than any configuration file
◦ except we seem to need more files (then they really should be well defined, well named, and in a common expected place)
◦ e.g. ~/.openhands/secrets/ maybe; what we have now is a bit messier
◦ I do think we can integrate keyring sometime, but we still need a fallback (files), it’s fine with care
Frankly, I am still to figure out
• why we save metadata at all in V1 (probably because there are multiple conversations even in the agent-server, this is confusing a bit because it also exists in app server, in db)
• and why it includes secrets (I don’t know this)
TL;DR:
We need to store secrets of more than one kind, and probably - apparently - in more than one file. I think we really should save them in one place, not per conversation.
It’s one agent server, it works in a single workspace => multiple conversations in that space have the same secrets, right?calm-artist-7206
10/21/2025, 10:40 PMstraight-sundown-84319
10/21/2025, 10:41 PMIt’s one agent server, it works in a single workspace => multiple conversations in that space have the same secrets, right?At the moment, the secrets are tied to the conversation rather than the workspace. So in theory you could have a workspace that has 2 conversations working in the same workspace - one for github, one for gitlab. (Or 2 different github accounts.) I suppose we could attach secrets to the workspace instead and then say if you want different accounts use a different workspace - this seems safer
straight-sundown-84319
10/21/2025, 10:41 PMcalm-artist-7206
10/21/2025, 10:42 PMstraight-sundown-84319
10/21/2025, 10:42 PMstraight-sundown-84319
10/21/2025, 10:42 PMstraight-sundown-84319
10/21/2025, 10:43 PMstraight-sundown-84319
10/21/2025, 10:44 PMstraight-sundown-84319
10/21/2025, 10:44 PMcalm-artist-7206
10/21/2025, 10:45 PMsecrets.json I think, they weren’t in the metadata filestraight-sundown-84319
10/21/2025, 10:46 PMcalm-artist-7206
10/21/2025, 10:47 PMstraight-sundown-84319
10/21/2025, 10:48 PMstraight-sundown-84319
10/21/2025, 10:48 PMcalm-artist-7206
10/21/2025, 10:56 PMsecrets instead, and then we could eliminate multiple files. Single, clear file.
If they are attached to the workspace… Definitely sounds better than to conversation, but does it mean the user could end up with more than one copy when they work on different projects, using LocalWorkspace successively?straight-sundown-84319
10/21/2025, 10:58 PMcalm-artist-7206
10/21/2025, 11:29 PMstraight-sundown-84319
10/21/2025, 11:35 PMwhy don’t we use Lookup mechanism on restore just as well as any other time?The lookup mechanism still needs to know which URL to lookup, and the key to use. If this were attached to the workspace rather than the conversation it would make more sense, as we would probably simply read it from the environment variables
straight-sundown-84319
10/21/2025, 11:37 PMstraight-sundown-84319
10/21/2025, 11:38 PMstraight-sundown-84319
10/21/2025, 11:39 PMstraight-sundown-84319
10/21/2025, 11:39 PMstraight-sundown-84319
10/21/2025, 11:39 PMstraight-sundown-84319
10/21/2025, 11:40 PMstraight-sundown-84319
10/21/2025, 11:40 PMcalm-artist-7206
10/21/2025, 11:41 PMcalm-artist-7206
10/21/2025, 11:57 PMcalm-artist-7206
10/22/2025, 1:16 AM