My one secret to share…

An article on how to expose secret values in Azure DevOps

Ștefan Pleșca
ING Hubs Romania
3 min readApr 7, 2022

--

Photo by Dima Pechurin on Unsplash

You already know by now about the paradox of security in general. You can secure anything as long as the protected object is beyond the reach of a potential attacker. Let me explain this a bit. Your laptop is secure while it is in your possession; when it leaves your hands, its security can be compromised. Your system can be secured almost 100% against external threats, but this percentage is drastically lower when securing against inside threats. This applies also to Azure DevOps and the secret values options that we have here. If the secret is needed in pipeline interactions, there is at least one way to expose it.

Context

Let’s create the scene for this short experiment:

  • Create 2 variables SECRET_VAR_1 (value: secretvar1) and SECRET_VAR_2 (value:secretvar2)
  • Mark them as secret
  • Save the setup

Some scripting magic

Let’s try a simple echo:

And the output:

Now we know that you can not simply echo a secret because you will get ***, so how about some splits :D

Let’s see it in PowerShell:

And the output:

How about some Bash:

And the output:

Tadaa!!! And those are just some working examples. Each time you split your secret and put it back together vertically, with spaces or with special characters as delimiters, you can expose it and thus read it.

No secret in that! (pun intended)

Short disclaimer

The fact that we can expose a secret variable here, does not make us hackers. Remember that! The functionality of secrets in most CI/CD systems is to have clean shareable logs, and not hide values from you, the admin, ops, or sysadmin. That would be crazy, right? :P

Before you leave…

I hope you enjoyed this exercise as I loved writing it! Remember that if you can touch it, you can know it. Stay tuned, follow, subscribe, share, leave a comment, and be as social as possible for the sake of the Social Media Gods! Will sign out now, and have a coffee offline :P

--

--

Ștefan Pleșca
ING Hubs Romania

I’m a creative senior DevOps engineer, AWS and Azure certified, fluent in Linux, Windows, scripting, and infrastructure automation. 100% Challenge driven! :-)