A common problem in software development is that security related activities are left out or deferred until the final testing phase, which is too late in the SDLC after most of the critical design and implementation has been completed. Besides, the security checks performed during the testing phase can be superficial, limited to scanning and penetration testing, which might not reveal more complex security issues. By adopting shift left principle, teams are able to detect and fix security flaws early on, save money that would otherwise be spent on a costly rework, and have a better chance of avoiding delays going into production.
Integrating security into SDLC should look like weaving rather than stacking. There is no “security phase,” but rather a set of best practices and tools that should be included within the existing phases of the SDLC. A Secure SDLC requires adding security review and testing at each software development stage, from design, to development, to deployment and beyond. From initial planning to deployment and maintenance, embedding security practices ensures the creation of robust and resilient software. A Secure SDLC not only helps in identifying potential vulnerabilities early but also reduces the cost and effort required to fix security flaws later in the development process. Despite the perceived overhead that security efforts add to, the impact from the security incident could be far more devastating than the effort of getting it right the first time around.
1. Planning
The planning phase sets the foundation for secure software development. During this phase, it’s essential to clearly establish the security strategy and objectives and develop a security plan, which shall be part and parcel of the product or project management plan. While doing so, it is important to take into account the contractual obligations with the client, regulatory requirements as may be relevant and applicable for the functional domain and the country and region where the product or project is likely to be executed and deployed. It is also important to define and document appropriate security policies as relevant to the project / product. The established Security strategies, objectives and the related implementation plan shall be diseminated to all stakeholders, so that they are aware of their roles and responsibilities in meeting the objectives and achieving these goals.
2. Requirements
In the requirements phase, security requirements should be explicitly defined and documented. Collaborate with stakeholders to understand the security needs of the application. Identify compliance requirements and industry standards that must be adhered to. Incorporate security considerations into functional and non-functional requirements. Ensure that security requirements are clear, measurable, and testable.
Security requirement gathering is a critical part of this phase. Without this effort, the design and implementation phases will be based on unstated choices, which can lead to security gaps. You might need to change the implementation later to accommodate security, which can be expensive.
During this phase, the Business Analysts shall gather relevant security requirements various sources and such requirements are of the following types:
- Security Drivers: The security drivers determine the security needs as per the industry standards, thereby shaping security requirements for the given software project or product. The drivers for security requirements include regulatory compliance like SarbanesOxley, Health Insurance Portability and Accountability Act (HIPAA), PCI DSS, Data Protection Regulaations etc.; industry regulations and standards like ISO, OASIS etc.; company policies like privacy policies, coding standards, patching policies, data classification policies etc.; and security features like authentication and authorization model, role-based access control, and administrative interfaces etc. The policies when transformed to detailed requirements demonstrate the security requirements. By using the drivers, managers can determine the security requirements necessary for the project.
- Functional Security Requirements (FSR): FSRs are the requirements that focus on the given product or project. The requirements for the FSRs can be gathered from the customers and end users. This may also contain security requirements as derived from the Security Drivers. These requirements are normally gathered by means of misuse cases which capture requirements in negative sense, like what should not happen or what should not be permitted. To ensure that the FSR is fully gathered, it is essential that the involved Business Analysts shall have the requisite level of exposure in Security related aspects or shall collaborate with Security Analysts.
3. Design
The design phase is where the Architects document the technical aspects of the software. This is a critical phase for incorporating security aspects with technical and implementation details into the software architecture. In this phase, the Architects shall consider the Drivers and FSRs documented in the Software Requirements Specification as documented in the previous phase. The following are some of the Non Functional security requirements that the Architects shall take into account while designing the Software Architecture.
- The Security dimension: The Architects shall Identify and document the security controls to be considered for protecting the system and interfaces exposed for third parties. For example, component / module segmentation strategy, the types of identities (both human and non-human) needed, authentication and authorization scheme, and the encryption methods to protect data, etc.
- Shared Responsibilities: It's important to understand and take into account the shared responsibility model of the cloud service provider or such other infrastructure service provider. It will be unnecessary to implement security controls within the system where the service provider has accepted the responsibility. However, it would be appropriate to factor aa conditional compensating controls, so that in the event of any breach on the service provider end, the compensating control could kick-in.
- System Dependencies: Clearly identify the third party or open source components or services to be used after evaluating the security risks associated with such components and services. If appropriate consider factoring additional security controls to compensate any known risks exposed by such components / services.
- Security Design Patterns: Design Patterns offer solutions for standard security concerns like segmentation and isolation, strong authorization, uniform application security, and modern protocols. The Architect shall explicitly call out the relevant and appropriate design patterns to be used by the development teams.
4. Development
During the development phase, secure coding practices are paramount. Educate developers on secure coding techniques and provide them with tools and resources to write secure code. The Developers shall be required to use static code analysis tools to identify and remediate security issues early in the development process. The developers shall have the mindset to expect the unexpected, so that all current and future scenarios are considered while building the software.
The following are some of the common practices that the developers shall adhere to while building the software:
- Input Validation: One of the most common entry points for attackers is through improperly validated inputs. Ensure that all user inputs are thoroughly validated and sanitized. Implement strong input validation techniques to prevent injection attacks, such as SQL injection and cross-site scripting (XSS). It is common that there would be multiple entry points for receiving inputs (e.g. web and mobile user interfaces, APIs, uploads, etc), in which case, the validation and sanitization shall be implemented in all such entry points.
- Write just enough code: When you reduce your code footprint, you also reduce the chances of security defects. Reuse code and libraries that are already in use and have been through security validations instead of duplicating code.
- Use Parameterized Queries: SQL injection attacks can be devastating, allowing attackers to execute arbitrary SQL code. To prevent this, always use parameterized queries or prepared statements when interacting with databases. This approach ensures that user inputs are treated as data, not executable code.
- Implement Authentication and Authorization: Authentication verifies the identity of users, while authorization determines their access levels. Use strong authentication mechanisms, such as multi-factor authentication (MFA), and implement role-based access control (RBAC) to ensure that users only have access to the resources they need.
- Deny-all approach by default: Create allowlists only for entities that need access. For example, if you have code that needs to determine whether a privileged operation should be allowed, you should write it so that the deny outcome is the default case and the allow outcome occurs only when specifically permitted by code.
- Encrypt Sensitive Data: Encryption is a critical component of secure coding. Encrypt sensitive data both at rest and in transit to protect it from unauthorized access. Use industry-standard encryption algorithms and ensure proper key management practices. With the quantum computing getting closer to commercial adoption, it is time to consider quantum safe encryption methods.
- Secure Session Management: Session hijacking can compromise user accounts. Implement secure session management practices, such as generating unique session IDs, using HTTPS, and setting appropriate session timeouts. Ensure that session tokens are securely stored and transmitted.
- Regularly Update and Patch Dependencies: Outdated libraries and dependencies can introduce vulnerabilities into your software. Regularly update and patch third-party libraries and components to ensure that known security flaws are addressed promptly.
- Implement Error Handling and Logging: Proper error handling and logging are crucial for identifying and mitigating security issues. Avoid exposing sensitive information in error messages. Use logging to track suspicious activities and potential security breaches.
- Conduct Code Reviews: Peer code reviews are essential steps in the development process. Conduct regular code reviews to identify potential security issues. Use automated tools for static and dynamic analysis to uncover vulnerabilities.
5. Testing
The testing phase of the SDLC typically happens after all new code has been written, compiled and the application is deployed in a test environment. This is another opportunity to perform tests in near production environment, even if earlier testing of source code already happened. The testing phase is where security vulnerabilities are identified and addressed. While there exist tools for performing securit testing, the human testers are required to be aware of various security scenarios and accordingly align their test strategy, choice of tools, the level of coverage, etc. Following are some of the widely practiced security testing methods, besides manual functional testing:
- Static Application Security Testing (SAST): SAST is a software testing method that analyzes an application's source code for vulnerabilities. It's also known as static analysis or white box testing. SAST analyzes an application's source code, byte code, and binaries. SAST can help identify vulnerabilities such as buffer overflows, SQL injection, and cross-site scripting (XSS). SAST is a white-box testing method that looks for vulnerabilities inside the application.
- Dynamic Application Security Testing (DAST): DAST is a black-box testing method that analyzes web applications for vulnerabilities by simulating attacks. DAST tests running applications in real-time to find security flaws. DAST evaluates applications from the "outside in". DAST tests for critical threats like cross-site scripting (XSS), SQL injection (SQLi), and cross-site request forgery (CSRF).
- Penetration Testing: A penetration test, also known as a pen test, is a simulated cyber attack against your application to check for exploitable vulnerabilities. The goal is to determine if the application is secure and can withstand potential attacks.
- Fuzz Testing: Fuzz testing is a software testing method that uses automated tools to identify bugs and vulnerabilities in web applications by feeding unexpected or invalid data to see how the application behaves or responds. The goal is to induce unexpected behavior, such as crashes or memory leaks, and see if it leads to an exploitable bug. Fuzz testing can uncover a wide range of vulnerabilities, including those that may not be detected through other testing methods.
6. Deployment
Securing the deployment phase of the Software Development Lifecycle (SDLC) involves ensuring that the software is ready for use and configured securely. This includes implementing access controls to protect the environment used for build and deployment, monitoring for vulnerabilities, and responding to security incidents. The following are some of the best practices to be practiced:
- Environment Hardening: Secure the deployment environment by disabling unnecessary services and applying security patches. Build agents are highly privileged and have access to the build server and the code. They must be protected with the same rigor as the workload components. This means that access to build agents must be authenticated and authorized, they should be network-segmented with firewall controls, they should be subject to vulnerability scanning, and so on.
- Secure the Source Code Repository: The source code repository must be safeguarded as well. Grant access to code repositories on a need-to-know basis and reduce exposure of vulnerabilities as much as possible to avoid attacks. Have a thorough process to review code for security vulnerabilities. Use security groups for that purpose, and implement an approval process that's based on business justifications.
- Protect the deployment pipelines: It's not enough to just secure code. If it runs in exploitable pipelines, all security efforts are futile and incomplete. Build and release environments must also be protected because you want to prevent bad actors from running malicious code in your pipeline.
- Up-to-date Software Bill of Materials (SBOM): Every component that's integrated into an application adds to the attack surface. Ensure that only evaluated and approved components are used within the application. On a regular basis, check that your manifest matches what's in your build process. Doing so helps ensure that no new components that contain back doors or other malware are added unexpectedly.
7. Maintenance
Security does not end with deployment; it is an ongoing process. During the maintenance phase, continuously monitor the application for security threats and vulnerabilities. Apply security patches and updates promptly. Conduct regular security audits and reviews to ensure compliance with security policies and standards. Educate users on security best practices and respond to security incidents swiftly.
Conclusion
Building secure software requires a holistic approach that integrates security into every phase of the SDLC. By adopting these best practices, organizations can create resilient applications that protect sensitive data and withstand cyber threats. Remember, security is a continuous journey, and staying vigilant is key to maintaining a secure software environment.