Forum Discussion

integralist's avatar
integralist
New Contributor
7 months ago
Solved

Security concern with allowing Terminal complete access to my 1P account via op CLI

I have a shell script that uses 1Password secret reference:


export EXAMPLE_API_KEY=$(op read "op://Vault-Name/Example API Token/Specific-Token/Token")

But when it's loaded, I have to authorise the terminal/shell to have access to it (see screenshot)

My concern is that it's giving the terminal/shell access to my entire account and all vaults within it when I only want to provide it with access to one entry within a single vault.

What happens if I had a malicious script installed that scans for 1Password secret references across multiple files? The script might not be able to identify the "account" but it just needs the vault names. Then it can start to build up common names for identifying secrets stored within 1Password and try requesting them, and if I've already authorised the terminal/shell I won't see a popup notification and so the script would be free to access the secrets.

Initially, I moved any secrets I use for development work into a separate vault, which I thought would help when it came to the terminal/shell requiring access via a 1Password secret reference because it would only have access to that specific vault (reducing the blast radius) but that's when I noticed it wasn't getting access to just the vault but the entire account.

I'm not sure how much of an issue people think this is but it worries me.


1Password Version: 8.10.40
Extension Version: Not Provided
OS Version: macOS 15.1
Browser: Chrome

  • Hi Integralist,

    This is a great question. I think this falls into the same category as risks associated with malware or similarly compromised devices: there's very little any application can do to prevent that entity from accessing any information on your computer that the authorized user can access. An attacker that has the same permissions you have on the device (as is true in the scenario you are referring to in which there is arbitrary malicious code being executed) can at least theoretically access anything you access. 

    The CLI behaviour you outline doesn't meaningfully increase the risk in a situation like this because such an attacker with the level of access you describe doesn't require the CLI to behave this way to do harm, including potentially learning something about your 1Password data, since 1Password is necessarily unlocked in your scenario. 

    It sounds trite, but the answer almost always is: It's never safe to run any application on a device that is, or suspected to be, compromised. If you suspect your device is compromised, you should not unlock 1Password. That should at least prevent the attacker from obtaining any 1Password data (as for all the other data on your computer... that's a different story). 

    We do our best to protect your data even in the event of a compromised device, which you can read a bit more about here: https://blog.1password.com/local-threats-device-protections/ 

    But at the end of the day, there's not a lot that any application can do to completely eliminate this risk. 1Password in it's locked state, however, would be almost an impossible nut to crack. 

6 Replies

  • bahamas's avatar
    bahamas
    New Contributor

    Hi Scott,

    I can see that this is a bit aged already, and there is already some changes to this. That said I'd like to put this stance into question.

    My use-case is to read out a given secret just like OP. If 1Password opens up the vault for free access for 10 minutes that is a completely different thing, than stating that App: X wants to read Developers/Key. On a compromised system only one key is vulnerable instead of all secrets. Of course it depends on how the system is compromised. All other aspects aside it is really bad UX, when the prompt says do you want to open up 1Password for free access to anything for 10 minutes, while 1password knows exactly what is asked to be retrieved. It confuses the user to say the least. Would it be possible to get a second opinion, maybe from someone close to the development team, if you don't feel that is you?

    I'm sorry if this comes out in a bad tone, but this prevents me from making a really neat integration, which I was really thrilled to provide to my team.

    • Scott_1P's avatar
      Scott_1P
      Icon for 1Password Team rank1Password Team

      Hi bahamas​ 

      I appreciate your thoughts here. 

      I think the difficulty is whether the risk being discussed can be effectively mitigated without creating substantial friction for end users.

      If I understand what you're suggesting, you're saying the 10 minute session timeout leaves all secrets vulnerable on a compromised device because you can `op item list....` without authentication for 10 minutes. 

      Whereas if the session closed immediately upon the CLI executing your command, as I believe you are proposing, only the retrieved value would be vulnerable in the threat scenario you're outlining. 

      If my understanding of your situation and hypothetical threat scenario is correct, I do not believe there is an effective way to mitigate that risk. 

      Risk mitigation

      I am not certain that mitigating this threat scenario is possible, nor would mitigating it (if possible) provide meaningful protection against an attacker capable of exploiting it. 

      • The scenario you describe involves a device compromised "in some way". At a minimum, to execute the hypothetical attack you describe, the attacker needs to be able to obtain values from your terminal, run commands in your terminal, or read your device's memory. 
        • An attacker with that level of access to your device may not ever engage in the described attack because they'd have sufficient control of your system to obtain other valuable information including information from 1Password. So closing this door may be closing a door nobody was going to break into anyway.  If they attempted to break into this door and we've managed to effectively prevent that, the attacker has the access they need to access other processes on your system, such as 1Password's desktop app, your browser, your terminal (as per the requirements of this attack) or perform some other malicious that rapidly terminating CLI session cannot mitigate. 
          • In theory immediate session termination does make that one specific thing a bit harder for an attacker, but not by much, and given the baseline level of access this attacker needs, would just cause them to pivot. 
      • Let's imagine, though, that we can stop an attacker from exploiting this behaviour, and the attacker is also unable to exploit any other part of your computer system despite their level of access (which is admittedly rather far-fetched).
        • It's likely you, or any given `op` user who chooses to enable this immediate session termination behaviour, may need to revert to more conventional `op` session handling to run a script or some such. In that case, unless you've completely mitigated the compromise, the attacker can now leverage that session behaviour.  
        • But practically speaking the attacker has enough access to your system they don't need to wait for you to disable the immediate session termination feature you describe. 

      UX

      Even if it's possible to do, mitigating this risk is of limited (but not zero) security value, there's a fairly massive user experience "cost" to implementing it that likely far outweighs the benefit. Especially since the alternative mitigation – not using a machine you suspect is being compromised – is far more effective and comes with no experience degradation. And if you are unaware that your machine is compromised, then you're likely in for a bad time no matter what `op` does. Even if the immediate session termination is an effective, you'd have to never change away from that behaviour while your machine, unbeknownst to you, remains compromised.

      • Terminating a session immediately upon a command being executed by the CLI would require the user to authenticate prior to executing each command. That's not a particularly great experience in most situations since in most situations people are executing many commands.
        • In theory this could be a "mode" or some optional setting, but that would introduce some product complexity and end-user complexity and, as described below, provide little meaningful security for the "cost".
      • If the CLI behaved this way, it would also go against how all other 1Password clients work: All 1Password clients can be unlocked and remain unlocked unless idle for X period (default is 10 minutes). Having the CLI behave the same way makes the experience predictable. 
        • The threat you describe also applies to 1Password's GUI clients just as much as the CLI.  Since this discussion centres around an auth prompt from 1Password's desktop app integration with `op`, I'm assuming that the desktop application is installed and unlocked. So in a situation where the CLI is being used on a compromised device,  then any malicious actor in a position to obtain values from the CLI is likely to be able to obtain at least some data from the 1Password desktop application as you use it over time. 

      At the core of it, you're right: It depends on how the system is compromised. However, the level of compromise required to pull off the attack you are describing is necessarily rather extensive, and would enable an attacker to do much more dire things. 

      To that end, given the impacts to the user experience by implementing a mitigation you describe, and the limited effectiveness of that mitigation (or any mitigation that 1Password itself can reasonably implement), I'm not sure this is a threat that 1Password itself can effectively mitigate on it's own. The most effective mitigation with the lowest negative impact to a user's productivity and experience with `op` would be to avoid using a device you suspect is compromised. 

      That said, I will pass this thread along to our security engineering team so they can share any additional thoughts they may have (though we cannot guarantee they will necessarily provide any or a detailed response). 

      Thanks for sharing your situation and if I have more to share from our internal teams I'll circle back. 

      Cheers,
      Scott

      • bahamas's avatar
        bahamas
        New Contributor

        Hi Scott,

        and thank you for your insightful and detailed reply. I understand that there are many details that I cannot take into account, due to my limited knowledge about 1Password. That said I would like to add that this should most likely be implemented as a new feature, not changing the flow for other use-cases. I'm thinking this would be an additional flag which would allow 1Password to be more restrictive, and specific. In my current use-case a single secret would be enough, and it would be possible to bundle more than one secret in a single field, if necessary.

        I can reveal that the use case is to script switching between stacks when managing infrastructure. I.e. when a Developer / DEVOPS engineer is accessing specific parts of the infrastructure the script would read the secrets necessary to access specific microservices or development or production environments, for updating or inspecting. It would give additional confirmation to the user what environment is being accessed, so the UX would be really good. Imagine picking a deployment for inspection and 1Password popping up to stating that Access is requested for SysAdmin / AWS / Service Deployment.

        The risk I was thinking about is the rising use of Agentic tools like Claude Code, where the problem is more of making mistakes than actually having a compromised system, in the traditional sense. That said the my primary concern here is confusing UX.

        It could make sense to allow retrieving multiple explicit secrets in one request, but I understand that it might add significant complexity to usage, as passing multiple secrets back to the requester requires some special encoding, and parsing. I agree that this would be a stretch.

  • Scott_1P's avatar
    Scott_1P
    Icon for 1Password Team rank1Password Team

    Hi Integralist,

    This is a great question. I think this falls into the same category as risks associated with malware or similarly compromised devices: there's very little any application can do to prevent that entity from accessing any information on your computer that the authorized user can access. An attacker that has the same permissions you have on the device (as is true in the scenario you are referring to in which there is arbitrary malicious code being executed) can at least theoretically access anything you access. 

    The CLI behaviour you outline doesn't meaningfully increase the risk in a situation like this because such an attacker with the level of access you describe doesn't require the CLI to behave this way to do harm, including potentially learning something about your 1Password data, since 1Password is necessarily unlocked in your scenario. 

    It sounds trite, but the answer almost always is: It's never safe to run any application on a device that is, or suspected to be, compromised. If you suspect your device is compromised, you should not unlock 1Password. That should at least prevent the attacker from obtaining any 1Password data (as for all the other data on your computer... that's a different story). 

    We do our best to protect your data even in the event of a compromised device, which you can read a bit more about here: https://blog.1password.com/local-threats-device-protections/ 

    But at the end of the day, there's not a lot that any application can do to completely eliminate this risk. 1Password in it's locked state, however, would be almost an impossible nut to crack.