Secrets can be leaked from both public and private repositories. The Lapsus Group has publicly released the source code of major companies, showing that private code is not safe. Source code is spread across various platforms, including developers' machines, backups, wikis, messaging systems, and Git repositories. Even if you don't have open source repositories, secrets should never be in your code. To prevent exposure, avoid hardcoding secrets and store keys on the backend instead of handling them directly on the front end.
Very frequently. One example that we had last year was with Toyota, where a contractor working for Toyota accidentally leaked public keys, accidentally made a private repository public, which leaked keys to a database that Toyota's mobile application was using, a mobile application called T-Connect. So these are keys that gave access to all the user's information that were using T-Connect that were sitting out there in a public repository. So this is just one example, but there's many, many, many more examples of where real keys belonging to organizations having real consequences have been leaked out in public places.
But it's not just public repositories that you need to worry about. It's your private repositories, too. Source code that is private is always accidentally finding its way out into public places, or as I call it, involuntarily open sourced. The Lapsus Group, for example, last year publicly released the source code of NVIDIA, Samsung, Microsoft and many, many more. You may ask, how did they gain access to private source code? Well, there's lots of different ways. Source code is a very leaky asset, which means it's sprawled everywhere. It's on your developers' machines, it's backed up, it's in wikis, it's shared over messaging systems, and of course, it's in your Git repositories. Also, a lot of people have access to your Git repositories. And I know for a fact that Lapsus was simply paying employees to grant them access to public private source code. So it's not that difficult for a threat actor that's motivated to access your private source code. So if you're thinking you're safe because you don't have open source repositories, you're not. Secrets definitely should not be in your code regardless of where they are.
So why do secrets get exposed? There's lots of different ways. Maybe you're committing things and you're testing out keys so you've hardcoded them in there, not realizing that those keys are going to be in your history forever. Even if you do something on a development branch, you hardcode credentials, you quickly remove them later because you're just testing it, those credentials are still going to be in your Git history and they're going to be there forever. They can be printed out in auto-generated files like debug logs. You can include sensitive files in your Git repositories like .env files or .pem files. They should never be in your repository so make sure you use a .gitignore file and you can also accidentally push code to the wrong place. So how do you prevent them from doing this? Well, you should never hard code secrets, never directly type in the secret into your application. That's rule number one, doesn't matter if it's private, public or what kind of branch you're working on or for how long it's there. It will be there forever in Git. We also can use tools to prevent them from being leaked. So we can use tools to enable us to do this. So we want to store keys on the backend. If you're building a React app and you're making it look pretty, we want to make sure that you're accessing your credentials through the backend and it's passing you the data that you need and you're not dealing with it directly. And there's not many scenarios where you actually need to handle those keys on the front end.
Comments