Sec+ Chapter 06: Secure Coding Flashcards
SDLC
Software development lifecycle
The process of designing, creating, supporting, and maintaining software. The eight phases of the SDLC are:
1) Feasibility
2) Analysis and requirements definition
3) Design
4) Development
5) Testing and integration
6) Training and transition
7) Ongoing operations and maintenance
8) Disposition
SDLC Feasibility phase
Where initial investigations into whether the effort should occur are conducted
Looks at alternative solutions and high-level costs for each solution proposed
Results in recommendation with a plan to move forward
SDLC Analysis and requirements definition phase
Get customer input to determine what the desired functionality is, what the current system or app does, what it doesn’t do, and what improvements are desired
SDLC Design phase
Design for functionality, architecture, integration points and techniques, dataflows, business processes, and other required elements
SDLC Development phase
The actual coding of the app
May involve unit testing, where small components are tested individually to ensure they function properly
SDLC Testing and integration phase
Formal testing with customers and others outside of the dev team
Individual units or software components are integrated and tested for proper functionality
Could also include connections to outside services, data sources, etc
UAT
User acceptance testing
A process to ensure that users are satisfied with the software and its functionality
SDLC Training and transition phase
Ensuring that end-users are trained on the software and that it has successfully entered general use
Also called acceptance, installation, and deployment phase
SDLC Ongoing operations and maintenance phase
Once the project has reached completion
Longest phase of the SDLC
Includes patching, updating, minor mods, and daily support
SDLC Disposition phase
When a product reaches the end of its life
Shutting down old products can save money, replacing existing tools may require specific knowledge or additional effort, and data and systems may need to be preserved or properly disposed of
Development environment
Used for devs to do their work
Sometimes each dev gets their own environment, sometimes it’s shared
Test environment
Software or systems can be tested here without impacting the production environment
QA takes place here
Staging environment
A transition environment for code that has successfully cleared testing and is waiting to be deployed into production
Real world environment that works and feels exactly like the production environment
Production environment
The live system where the work is rolled out to the user community
Software, patches, and other changes that have been tested and approved move to production
Waterfall development
A sequential SDLC methodology in which each phase is followed by the next
Phases don’t overlap, and each logically leads to the next
Not always the first choice due to its inflexibility, but still used for complex systems
Phases of waterfall development
1) Requirements are gathered and documented
2) Analysis to build business rules and models
3) Software architecture is designed
4) Coding and integration of software
5) Testing and debugging
6) Operational phase with support, maintenance, and ongoing operations activities
Spiral development
Uses the linear concepts from Waterfall and adds a flexible, iterative process that revisits four phases multiple times during the SDLC to gather more detailed requirements, design functionality guided by requirements, and build based on design
Heavy emphasis on risk assessment
Phases of spiral development
1) Identification / requirements gathering, which gathers business reqs, system reqs, and detailed reqs for subsystems or modules
2) Design, conceptual, architectural, logical, and sometimes physical or final design
3) Build, which produces an initial proof of concept and then further development releases until the final production build is produced
4) Evaluation, which involves risk analysis for the development project to monitor the feasibility of delivering the software from a technical and managerial viewpoint. Customer testing and feedback
Agile development
Breaks up work into smaller units, and work is broken up into sprints
Rooted in 4 premises:
1) Individuals and interactions are more important than processes and tools
2) Working software is preferable to comprehensive documentation
3) Customer collaboration replaces contract negotiation
4) Responding to change is key, don’t just follow the plan
12 Principles of Agile
1) Ensure customer satisfaction with early and continuous delivery of software
2) Welcome changing requirements, even late in the dev process
3) Deliver working software frequently (weeks > months)
4) Ensure daily cooperation between devs and businesspeople
5) Projects should be built around motivated individuals who get support, trust, and environment they need
6) Face-to-face convos are the most efficient way to convey information inside the dev team
7) Progress is measured by working software
8) Dev should be done at a sustainable pace that can be maintained daily
9) Pay attention to technical excellence and good design
10) Simplicity is essential
11) The best architectures, requirements, and designs emerge from self-organizing teams
12) Teams should reflect on how to be more effective, and then implement that behavior regularly
CI
Continuous integration
A development practice that checks code into a shared repository on a consistent, ongoing basis
The goal is to enable the use of automation and scripting to implement automated courses of action that result in continuous delivery of code
You also need automated security checks that evaluate the updated code with your existing security baselines
Ensure anything deployed to production is as safe as possible
CD
Continuous deployment
Rolls out tested changes into production automatically as soon as they’ve been tested
You can automate security checks during the testing process, and if a problem is found the app won’t be deployed
Security best practices in CI/CD
Logging, reporting, and continuous monitoring must be designed to fit into the CI/CD process to avoid rogue devs inserting flawed or malicious code
OWASP
Open web application security project
The home of a broad community of devs and security practitioners
Provides a regularly updated list of proactive controls that serve as best practices, but also how web app security threats change year to year
API
Application programming interface
Serves as interface between clients and servers, or apps and OS
Defines how a client should ask for info from the server and how the server responds
What does API security rely on?
Authentication
Authorization
Proper data scoping to ensure that too much data isn’t released
Rate limiting
Input filtering
Appropriate monitoring and logging
BONUS: Secure underlying systems, configure API endpoint server or service, and provide normal network layer security to protect the service
Pair programming
Agile dev technique that puts two devs at one workstation
One writes the code, the other reviews the code as it’s written
Provides real-time code review and ensures multiple devs are familiar with the code that’s written
Over the shoulder
Dev who writes the code explains it to the other dev
Allows peer review of code and can assist devs in understanding how the code works
Pass around code review
AKA: Email pass around code review
Form of manual peer review done by sending completed code to reviewers who check it for issues
Tool assisted reviews
This relies on formal or informal software-based tools to conduct code reviews
EX: Atlassian’s Crucible collaborative code review tool, Codacy’s static code review tool, and Phabricator’s Differential code review tool
Fagan inspection
A structured, formal code review intended to find a variety of problems during the dev process
It specifies entry and exit criteria for processes, ensuring that a process isn’t started before appropriate diligence has been performed
6 phases of the Fagan inspection
1) Planning: Prep of materials, attendees, location
2) Overview: Prepares a team by reviewing the materials and assigning roles like coder, reader, reviewer, and mod
3) Preparation: Review the code and document issues or questions
4) Meeting: Identify defects based on notes from prep phase
5) Rework: Resolve issues
6) Follow up: Ensure all issues identified have been found and that no new defects were created during resolution process
Static code analysis
AKA: source code analysis
Conducted by reviewing the code for an app
Can be a type of white box testing with full visibility to the testers
Can be conducted with automated tools, or manually by reviewing the code (code understanding)
Automation needs to be reviewed though, since you could turn false positives on issues
Dynamic code analysis
Relies on the execution of the code while providing it with input to test the software
Strong preference for automated testing due to the volume of tests needed
Fuzzing
AKA: Fuzz testing
Sends invalid or random data to an app to test its ability to handle unexpected data. The app is monitored to determine if it crashes, fails, or responds, in an incorrect manner
Usually automated
Useful for detecting input validation and logic issues as well as memory leaks and error handling
Injection vulnerabilities
One of the primary mechanisms an attacker will use to break through a web app and gain access to the systems supporting it
Attacker supplies code to the web app as input and tricks the web server into either executing that code or supplying it to another server to execute
SQL injection attack
Attack that interferes with the queries a web app makes to its database
Allows attackers access to sensitive data modify db data, execute admin operations on db, recover content of a file, and issue commands to the OS