Secure Coding Best Practices for 2022
Written by Sigal Zigelboim   
Monday, 19 September 2022
Article Index
Secure Coding Best Practices for 2022
Securing the CI/CD Pipeline

Securing the CI/CD Pipeline

A CI/CD pipeline combines continuous integration (CI) and continuous delivery or deployment (CD) into one efficient and highly automated process. DevOps and DevSecOps teams utilize CI/CD pipelines to automate the application development phases so they can consistently deliver applications to clients. 

While a CI/CD pipeline helps deliver applications quickly and efficiently, it does not necessarily keep them secure. A CI/CD pipeline provides many benefits but can also introduce security concerns due to its speed and lack of visibility. Common risks include security misconfigurations, supply chain attacks, insufficient access controls, secrets exposure, and flawed third-party libraries. 

Teams can mitigate these risks by prioritizing security throughout the CI/CD process, applying measures such as: 

  • Continuous monitoring—notifies teams when issues occur to facilitate quick remediation.

  • Access control—ensuring developers and collaborators have only the least privileges they need to perform their roles, and privileges are regularly reviewed and revoked if no longer necessary.

  • Network security—implementing firewalls, intrusion detection and prevention (IDS/IPS) systems, logging and auditing for all pipeline changes. 

Authentication and Session Management

Implementing strong authentication, in the form of session and identity management controls on the server side, can help minimize the probability of user session hijacking or exploited compromised credentials. Here are common controls to use: 

  • Multi-factor authentication (MFA)—this technique requires users to verify their identity using more than one factor. For example, asking for fingerprints in addition to passwords. MFA offers greater security, especially when implemented alongside secure password storage and recovery mechanisms. 

  • Conservative timeout and inactivity periods—these mechanisms can help prevent threat actors from exploiting user sessions and keep user data secure with minimal impact on user experience. Additionally, limit the number of concurrent sessions to ensure only legitimate users can access a website or application.  

Strong Encryption

Encryption techniques make data meaningless to prevent unauthorized entities from reading it. It typically involves using encryption tools created by cryptography experts to encrypt data with keys. Improper key management can introduce risks even when using the strongest cryptography. Teams can mitigate this risk by storing keys separately from the encrypted data and using a hardware security module (HSM).

Conclusion

In this article, I explained the concept of secure coding and showed that even in 2022, the majority of developers say they do not have sufficient security expertise. I provided several best practices that can help developers level up their skills and adopt secure coding: 

  1. Validation of inputs and encoding of outputs—ensuring that inputs from malicious users cannot execute malicious instructions in the operating environment, and that outputs do not divulge sensitive data to unauthorized users.

  2. Authentication and session management—ensuring all users are securely authenticated and the application does not allow for session hijacking.

  3. Error handling and logging—ensuring all errors and unexpected business logic conditions are handled in the code, logged, and do not display overly descriptive error messages.

  4. Strong encryption—ensuring the application encrypts all sensitive data at rest and in transit.

  5. Shift-left security—making all efforts to ensure security testing and remediation happens as early as possible in the software development life cycle.

  6. Securing the CI/CD pipeline—ensuring the CI/CD infrastructure itself is secure and controls are in place to prevent unauthorized access. 

I hope this will be useful as your development team levels up its security skills in preparation for a DevSecOps future.

securecodingsq 

 

More Information

Secure Code Warrior 2022 survey

Related Articles

Insights Into Successful Software Delivery

Happy Developers Think More About Security

The State Of Secure Software Development - Three OpenSSF Courses

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.

 

Banner


Open Platform For Enterprise AI Launched
18/04/2024

A new platform aimed at building and supporting an open artificial intelligence (AI) and data community has been launched.  The Open Platform for Enterprise AI (OPEA) was announced by The Linux F [ ... ]



GitHub Introduces Code Scanning
26/03/2024

GitHub has announced a public beta of a code scanner that automatically fixes problems. The new feature was announced back in November, but has now moved to public beta status.  


More News



Last Updated ( Friday, 07 October 2022 )