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

November 20, 2024

Spectro Cloud completed a $75 million Series C funding round led by Growth Equity at Goldman Sachs Alternatives with participation from existing Spectro Cloud investors.

November 20, 2024

The Cloud Native Computing Foundation® (CNCF®), which builds sustainable ecosystems for cloud native software, has announced significant momentum around cloud native training and certifications with the addition of three new project-centric certifications and a series of new Platform Engineering-specific certifications:

November 20, 2024

Red Hat announced the latest version of Red Hat OpenShift AI, its artificial intelligence (AI) and machine learning (ML) platform built on Red Hat OpenShift that enables enterprises to create and deliver AI-enabled applications at scale across the hybrid cloud.

November 20, 2024

Salesforce announced agentic lifecycle management tools to automate Agentforce testing, prototype agents in secure Sandbox environments, and transparently manage usage at scale.

November 19, 2024

OpenText™ unveiled Cloud Editions (CE) 24.4, presenting a suite of transformative advancements in Business Cloud, AI, and Technology to empower the future of AI-driven knowledge work.

November 19, 2024

Red Hat announced new capabilities and enhancements for Red Hat Developer Hub, Red Hat’s enterprise-grade developer portal based on the Backstage project.

November 19, 2024

Pegasystems announced the availability of new AI-driven legacy discovery capabilities in Pega GenAI Blueprint™ to accelerate the daunting task of modernizing legacy systems that hold organizations back.

November 19, 2024

Tricentis launched enhanced cloud capabilities for its flagship solution, Tricentis Tosca, bringing enterprise-ready end-to-end test automation to the cloud.

November 19, 2024

Rafay Systems announced new platform advancements that help enterprises and GPU cloud providers deliver developer-friendly consumption workflows for GPU infrastructure.

November 19, 2024

Apiiro introduced Code-to-Runtime, a new capability using Apiiro’s deep code analysis (DCA) technology to map software architecture and trace all types of software components including APIs, open source software (OSS), and containers to code owners while enriching it with business impact.

November 19, 2024

Zesty announced the launch of Kompass, its automated Kubernetes optimization platform.

November 18, 2024

MacStadium announced the launch of Orka Engine, the latest addition to its Orka product line.

November 18, 2024

Elastic announced its AI ecosystem to help enterprise developers accelerate building and deploying their Retrieval Augmented Generation (RAG) applications.

Read the full news on APMdigest

November 18, 2024

Red Hat introduced new capabilities and enhancements for Red Hat OpenShift, a hybrid cloud application platform powered by Kubernetes, as well as the technology preview of Red Hat OpenShift Lightspeed.

November 18, 2024

Traefik Labs announced API Sandbox as a Service to streamline and accelerate mock API development, and Traefik Proxy v3.2.