Security and the Twelve-Factor App - Step 1
A blog series by WhiteHat Security
June 07, 2018

Eric Sheridan
WhiteHat Security

The Twelve-Factor App is a methodology that offers a 12-step best practice approach for developers to apply when building software-as-a-service apps that are both scalable and maintainable in a DevOps world. As software continues to be written and deployed at a faster rate and in the cloud, development teams are finding there is more room for failure and vulnerabilities. This blog series will discuss how to build a Twelve-Factor app securely.

This first blog in the series looks at Step I, Codebase, in more detail.

Defining Codebase in the Twelve-Factor App

According to 12factor.net, a Twelve-Factor app is always tracked in a version control system, for example Git, Mercurial or Subversion. A copy of the revision tracking database is referred to as a "code repository," which developers often shorten to "code repo" or simply "repo."

A "codebase" is therefore any single repo, or set of repos, that share a common root, in a decentralized revision control system. The Twelve-Factor advocates putting all code into one repository or source control system that is tracked in revision control. So essentially there is only one codebase per app, but there can be many deploys of the app.

Applying Security to Codebase

Having one codebase tracked in revision control, with many deploys is the ideal, but it’s important to remember that your code is only as secure as the systems used to build it. As the guardian of the code and the systems in which it is housed, what steps can you as a developer take to ensure that the repository is properly secure?

1. Lock it down

These days source code is the core of most businesses, therefore it’s imperative to protect it. The best way to do this is by imposing restrictions — limit access to the source code repository to authenticated users only. Believe it or not it’s very common for people to be able to view the entire source code when on the internal network. While this maintains integrity, unfortunately it can put your entire intelligent property at risk.

Limit commits to pull requests as opposed to direct commits. This refers to a source management system model, in which no one can write directly to the source code repository. Pull requests are reviewed by the team responsible for the master code, which then decide whether to merge the new code with the existing base, or not. In this way the codebase is protected through the provision of checks and balances. Ultimately, limiting commits is an enabling requirement that acts as a shield for other activities.

2. No more secrets

Write code as if everything you did was open sourced. To share a practical example of this, there’s a scene in the movie Sneakers (1992) where Robert Redford’s character realizes that "Setec Astronomy," the name of the project that produced a black box, was actually an anagram for "Too Many Secrets." Soon after, Redford’s engineers realized that the black box was actually a piece of hardware capable of decrypting anything and everything — to which Redford then famously (at least for me) said "No More Secrets." In the same way we need to apply the idea of "No More Secrets" to our code. It means developers should write application code with the assumption that it could be disclosed, so ideally the goal will be to have no secrets in the actual application.


Externalize secrets and make their location known via startup arguments. This means putting secrets into configuration files where people can find them. Use the environment to protect the configuration.

3. Review code regularly

Enforce secure coding guidelines via a review of all pull requests. Throughout the software development stage, there are only a few key inflection points i.e. central areas where everything merges, where changes can be made. It’s a good policy to use these central points to enforce your company’s security guidelines. From a coding point of view these guidelines can include:

a. Use organizationally approved cryptographic controls.

b. Make use of HTTP security headers for all responses.

c. Consistent use of contextual encoding via HTML templating engines.

d. All database queries are performed using variable binding.

e. Keeping your dependencies updated.

Successful development teams find it’s equally important is to educate the team regarding solutions to pull requests that fail code reviews. It’s key to understand why some pull requests are rejected, and how the team can work to avoid these issues.

Teamwork

Collaborating in terms of sharing feedback will go a long way towards promoting awareness, and ultimately supporting the coding of applications that can be done more quickly, efficiently and securely. It’s an approach that should in fact be applied to all 12 steps of Twelve Factor.

Read Security and the Twelve-Factor App - Step 2

Eric Sheridan is Chief Scientist at WhiteHat Security
Share this

Industry News

March 25, 2025

Chainguard announced Chainguard Libraries, a catalog of guarded language libraries for Java built securely from source on SLSA L2 infrastructure.

March 25, 2025

Cloudelligent attained Amazon Web Services (AWS) DevOps Competency status.

March 25, 2025

Platform9 formally launched the Platform9 Partner Program.

March 24, 2025

Cosmonic announced the launch of Cosmonic Control, a control plane for managing distributed applications across any cloud, any Kubernetes, any edge, or on premise and self-hosted deployment.

March 20, 2025

Oracle announced the general availability of Oracle Exadata Database Service on Exascale Infrastructure on Oracle Database@Azure(link sends e-mail).

March 20, 2025

Perforce Software announced its acquisition of Snowtrack.

March 19, 2025

Mirantis and Gcore announced an agreement to facilitate the deployment of artificial intelligence (AI) workloads.

March 19, 2025

Amplitude announced the rollout of Session Replay Everywhere.

March 18, 2025

Oracle announced the availability of Java 24, the latest version of the programming language and development platform. Java 24 (Oracle JDK 24) delivers thousands of improvements to help developers maximize productivity and drive innovation. In addition, enhancements to the platform's performance, stability, and security help organizations accelerate their business growth ...

March 18, 2025

Tigera announced an integration with Mirantis, creators of k0rdent, a new multi-cluster Kubernetes management solution.

March 18, 2025

SAP announced “Joule for Developer” – new Joule AI co-pilot capabilities embedded directly within SAP Build.

March 17, 2025

SUSE® announced several new enhancements to its core suite of Linux solutions.

March 13, 2025

Progress is offering over 50 enterprise-grade UI components from Progress® KendoReact™, a React UI library for business application development, for free.

March 13, 2025

Opsera announced a new Leadership Dashboard capability within Opsera Unified Insights.

March 13, 2025

Cycloid announced the introduction of Components, a new management layer enabling a modular, structured approach to managing cloud resources within the Cycloid engineering platform.