Fundamentals of Secure Application Development
Plan security activities for each stage of building a feature, from requirements and secure coding to dependency checks, error handling and testing.
Inspections at every stage, not only at handover
Rohan Iyer has been asked to add a new feature to the Tulsi Health app: a monthly reminder that lets regular customers like Mrs. Gokhale reorder their medicines with one tap. Last year a similar feature went live and a tester found, three days later, that anyone could reorder for anyone else. Fixing it meant pulling the feature, rewriting half of it and apologising to customers. This time Vikram wants security built in from the first conversation, not bolted on at the end. That way of working has a name: a secure software development lifecycle, the normal steps of building software with a security activity added to every one of them.
Building software the way a careful builder builds a house
The software development lifecycle, or SDLC, is the series of stages every piece of software passes through: deciding what it must do (requirements), planning how it will work (design), writing the code, testing it, releasing it, and then looking after it while people use it. Many teams leave security to a single check just before release. By then, a problem in the design is buried under weeks of code, just as a crack in a foundation is buried under walls and plaster.
A careful builder in Pune does not wait for the finished flat to call the inspector. The plan is checked before digging, the foundation before the walls go up, the wiring before it is plastered over, and the whole building again before handover. Each check is quick because it looks at one stage, and each problem is cheap to fix because nothing has been built on top of it yet. A secure SDLC applies the same idea to software.
Each inspection looks at one stage while it is still easy to fix. A secure SDLC puts a security check at every stage of software in the same way.
Every stage gets its own small security activity, and what is learnt while maintaining the app feeds the next round of requirements.
For the reorder feature, the requirement now says "a customer can reorder only their own past orders". During design, Rohan and Neha Kulkarni spend twenty minutes asking how someone could misuse the feature, a habit called threat modelling: could a person reorder for someone else, change the quantity to 500, or replay an old prescription that has expired? Each answer becomes a rule the code must follow and a test the feature must pass.
Secure coding principles
Secure coding principles are habits that prevent whole families of mistakes, whatever language the code is written in. Rohan does not need to remember every possible attack, only to follow a short set of rules every time he writes code that touches users' data.
Each rule closes a whole family of weaknesses, which is why they are worth more than memorising individual attacks.
Keeping secrets out of code deserves a special mention. A secret here means a password or key that lets the app reach something, such as the database password. If it is typed straight into the code, everyone who can read the code, and anyone who ever gets a copy of it, has the password. Secrets belong in a separate, locked store that the app reads when it starts.
Code you did not write: secure dependencies
Almost no app is written from scratch. Rohan's app uses dozens of libraries, ready-made pieces of code written by others, for drawing charts, sending SMS messages or checking phone numbers. The app depends on them, so they are called dependencies. They save months of work, the way a builder buys bricks and wiring instead of making them, but a flaw in a brick is a flaw in the wall. When a weakness is found in a popular library and published, attackers start looking for every app that still uses the old version.
Secure dependencies come from a few habits. Keep a list of every library the app uses and its version. Download them only from the official source. Use a dependency check, a tool that compares that list against public lists of known weaknesses and warns when a version has one. And update regularly, removing libraries nobody uses any more, because every extra library is one more part to keep track of.
When things go wrong: secure error handling
Every app meets errors: a database that does not reply, a payment that times out, a form filled in strangely. Secure error handling means two things. First, the app fails safely: if it cannot confirm that a payment succeeded, it does not mark the order as paid, and if it cannot confirm who someone is, it refuses. Second, it says little to the user and a lot to the team. The user sees a short, plain message with a reference number; the full details go into a private log that only the team can read.
The unsafe version gives an attacker a map of the system and leaves the order in a wrong state. The safe version tells the customer what they need and the team what they need.
Put the secure lifecycle for the reorder feature in order below. Think about which checks need something to look at: you cannot review code that has not been written, or test a feature that does not run yet.
Basic security testing before release
Security testing means deliberately checking that the app resists misuse, not just that it works when used properly. A beginner team can do a lot with a few basic methods. In a code review, a second developer reads the changes looking for missing checks, unencoded output and secrets in the code. Automated scanning uses tools that read the code, or poke at the running app, to spot common mistakes quickly. The dependency check covers the libraries. And abuse tests try the things a misuser would try: changing the order number, sending a quantity of 500, opening the staff page from a customer account. Larger companies also hire authorised testers to attack the app with written permission, which finds what everyone else missed.
No single check catches everything, so the team layers them like the inspections on a building site. Choose which checks to put in Tulsi Health's release pipeline below, meaning the series of checks every change passes through before it reaches customers. Stay within the budget, then run the problems that might be hiding in the reorder feature and see which ones each check catches.