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

April 17, 2024

CIQ launched fully supported, upstream stable kernels for Rocky Linux via the CIQ Enterprise Linux Platform, providing enhanced performance, hardware compatibility and security.

April 17, 2024

Redgate launched an enterprise version of its database monitoring tool, providing a range of new features to address the challenges of scale and complexity faced by larger organizations.

April 17, 2024

Snyk announced the expansion of its current partnership with Google Cloud to advance secure code generated by Google Cloud’s generative-AI-powered collaborator service, Gemini Code Assist.

April 16, 2024

Kong announced the commercial availability of Kong Konnect Dedicated Cloud Gateways on Amazon Web Services (AWS).

April 16, 2024

Pegasystems announced the general availability of Pega Infinity ’24.1™.

April 16, 2024

Sylabs announces the launch of a new certification focusing on the Singularity container platform.

April 15, 2024

OpenText™ announced Cloud Editions (CE) 24.2, including OpenText DevOps Cloud and OpenText™ DevOps Aviator.

April 15, 2024

Postman announced its acquisition of Orbit, the community growth platform for developer companies.

April 11, 2024

Check Point® Software Technologies Ltd. announced new email security features that enhance its Check Point Harmony Email & Collaboration portfolio: Patented unified quarantine, DMARC monitoring, archiving, and Smart Banners.

April 11, 2024

Automation Anywhere announced an expanded partnership with Google Cloud to leverage the combined power of generative AI and its own specialized, generative AI automation models to give companies a powerful solution to optimize and transform their business.

April 11, 2024

Jetic announced the release of Jetlets, a low-code and no-code block template, that allows users to easily build any technically advanced integration use case, typically not covered by alternative integration platforms.

April 10, 2024

Progress announced new powerful capabilities and enhancements in the latest release of Progress® Sitefinity®.

April 10, 2024

Buildkite signed a multi-year strategic collaboration agreement (SCA) with Amazon Web Services (AWS), the world's most comprehensive and broadly adopted cloud, to accelerate delivery of cloud-native applications across multiple industries, including digital native, financial services, retail or any enterprise undergoing digital transformation.

April 10, 2024

AppViewX announced new functionality in the AppViewX CERT+ certificate lifecycle management automation product that helps organizations prepare for Google’s proposed 90-day TLS certificate validity policy.

April 09, 2024

Rocket Software is addressing the growing demand for integrated security, compliance, and automation in software development with its latest release of Rocket® DevOps, formerly known as Aldon®.