Earlier quoted context omitted.
The powershell script is a minor part of the screw up. The real issues are multitude... 1) hardcoding actual production credentials in a script at all. Seriously what the fuck. 2) Thycotic not enforcing MFA for the keys to the kingdom admin account. Even my cellphone provider has better security. The root cause is likely the assumption that the VPN is sacred. This needs to die asap - your internal network should assu…
I'm curious what's the alternative if the script must have those credentials to do its job.
Consider how an AWS instance runs code that is able to ... talk back to the rest of the AWS system.
For code that is not being directly run by a tethered meatball, use some form of workload identity [1].
When you are talking to another system that that can't understand your workload identity (legacy apis, etc.), keep those credentials in a tool like Vault[2], Secret Manager[3], etc. That system can/should handle credential rotation wherever possible, but it also ensures that the workload running the script is authorized to access the credentials in question. This is far superior to passing via env vars, but even that is better than hard-coding in the script itself. Oh, and using a memory-backed mount that contains those vars is better than env vars because there's less risk of leaking those when you fork.
Key points:
- externalize all secrets
- prefer workload identity
- prefer a workload identity aware secret store / manager
- fall back to fs mounted secrets and then env vars
[2] https://www.vaultproject.io
[3] https://docs.aws.amazon.com/secretsmanager/latest/userguide/...
edit: formatting now that I'm on a desktop