<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.2.2">Jekyll</generator><link href="https://www.occamslabs.com/feed.xml" rel="self" type="application/atom+xml" /><link href="https://www.occamslabs.com/" rel="alternate" type="text/html" /><updated>2024-06-11T09:57:18+00:00</updated><id>https://www.occamslabs.com/feed.xml</id><title type="html">OccamsLabs</title><subtitle>OccamsLabs helps you to set up efficient and useful security systems that are not in the way.</subtitle><author><name>Andreas Tiefenthaler</name><email>contact@occamslabs.com</email></author><entry><title type="html">Navigating the Shift: Traditional IT Security in the Age of DevSecOps</title><link href="https://www.occamslabs.com/security/devsecops/2024/05/01/navigating-the-shift-traditional-it-security-in-the-age-of-devsecops/" rel="alternate" type="text/html" title="Navigating the Shift: Traditional IT Security in the Age of DevSecOps" /><published>2024-05-01T03:23:00+00:00</published><updated>2024-05-01T03:23:00+00:00</updated><id>https://www.occamslabs.com/security/devsecops/2024/05/01/navigating-the-shift-traditional-it-security-in-the-age-of-devsecops</id><content type="html" xml:base="https://www.occamslabs.com/security/devsecops/2024/05/01/navigating-the-shift-traditional-it-security-in-the-age-of-devsecops/">&lt;p&gt;The shift from traditional IT security approaches to integrated DevSecOps practices in the rapidly evolving information technology landscape marks a significant transformation. This integration, blending development, operations, and security, challenges traditional IT security professionals to adapt to a faster, more agile environment.&lt;/p&gt;

&lt;h2 id=&quot;background-on-traditional-it-security&quot;&gt;Background on Traditional IT Security&lt;/h2&gt;

&lt;p&gt;Traditionally, IT security has focused primarily on perimeter defense, guarding against external threats with a clear boundary between ‘inside’ and ‘outside’. Security teams operated in silos, with distinct roles that rarely overlapped with those of developers or operations staff. Their work was largely reactive: identifying and mitigating threats and ensuring compliance with external standards and regulations.&lt;/p&gt;

&lt;h2 id=&quot;the-rise-of-devsecops&quot;&gt;The Rise of DevSecOps&lt;/h2&gt;

&lt;p&gt;DevSecOps represents a paradigm shift in how organizations approach software development and security. At its core, DevSecOps integrates security as a shared responsibility throughout the application development lifecycle rather than as a final checkpoint before deployment. This methodology emphasizes automation, continuous integration and deployment (CI/CD), and a proactive stance on security.&lt;/p&gt;

&lt;p&gt;The culture of DevSecOps is fundamentally collaborative, breaking down traditional silos and encouraging ongoing communication between developers, operations, and security teams. This integration ensures that security considerations are not an afterthought but are integrated into the daily workflows of all team members.&lt;/p&gt;

&lt;h2 id=&quot;core-challenges-for-traditional-it-security-professionals&quot;&gt;Core Challenges for Traditional IT Security Professionals&lt;/h2&gt;

&lt;p&gt;The transition to DevSecOps presents several challenges for traditional IT security professionals:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Shift from Gatekeeper to Collaborator:&lt;/strong&gt; Traditionally, security teams acted as gatekeepers, deciding what could be deployed and when. In DevSecOps, the role transforms into that of a collaborator, continuously working alongside others to embed security into the pipeline. It requires a shift in mindset from controlling to enabling.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Automation of Security Tasks:&lt;/strong&gt; DevSecOps relies heavily on automation to ensure security at speed and scale. Security professionals must now understand and develop automated tools and scripts, a significant departure from their conventional, often manual, security practices.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Culture and Mindset Change:&lt;/strong&gt; Perhaps the most significant challenge is the cultural shift required. Traditional security often operates under a risk-averse, ‘say no’ mindset. DevSecOps, by contrast, advocates for a risk management approach where security risks are balanced with business needs. This culture also emphasizes continuous improvement and learning, which can be a departure for those accustomed to static security environments.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;skills-and-mindset-adjustments-needed&quot;&gt;Skills and Mindset Adjustments Needed&lt;/h2&gt;

&lt;p&gt;To thrive in DevSecOps environments, traditional IT security professionals must develop both new skills and a new mindset:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Technical Skills: Proficiency in automation tools, an understanding of secure coding practices, and familiarity with cloud-native technologies are essential. Knowledge of CI/CD methodologies and the ability to write and understand code can significantly enhance a security professional’s effectiveness in a DevSecOps environment.
Adaptive Mindset: It is crucial to embrace a growth mindset, viewing challenges as opportunities to learn rather than obstacles. Security professionals must be willing to step out of their comfort zones and engage continuously with new tools, technologies, and methodologies.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;bridging-the-gap-strategies-for-transition&quot;&gt;Bridging the Gap: Strategies for Transition&lt;/h2&gt;

&lt;p&gt;Successfully integrating traditional IT security professionals into DevSecOps teams involves strategic initiatives and supportive leadership:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Education and Training:&lt;/strong&gt; Continuous learning opportunities, such as workshops, courses, and certifications, can help traditional security professionals update their skills to align with DevSecOps requirements.
&lt;strong&gt;Cross-Functional Collaboration:&lt;/strong&gt; Facilitating shadowing programs, where security professionals work closely with DevOps teams, can help build understanding and appreciation of each other’s roles and challenges.
&lt;strong&gt;Incremental Involvement:&lt;/strong&gt; Gradually involving security teams in DevSecOps projects can help ease the transition. Starting with minor, low-risk projects can build confidence and competence in the new environment.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;The evolution from traditional IT security to DevSecOps is not merely a change in technology or processes but a significant cultural shift. For conventional security professionals, adapting to this new environment requires a change in mindset from being gatekeepers to enablers, from working in silos to collaborating across functions, and from focusing solely on security to balancing security with speed and innovation.&lt;/p&gt;

&lt;p&gt;As organizations continue to embrace DevSecOps, the role of the IT security professional will only grow in complexity and importance. By adopting these changes, traditional security professionals can survive and thrive in this new landscape, contributing to safer, more resilient systems.&lt;/p&gt;</content><author><name>Andreas Tiefenthaler</name><email>contact@occamslabs.com</email></author><category term="security" /><category term="devsecops" /><summary type="html">The shift from traditional IT security approaches to integrated DevSecOps practices in the rapidly evolving information technology landscape marks a significant transformation. This integration, blending development, operations, and security, challenges traditional IT security professionals to adapt to a faster, more agile environment.</summary></entry><entry><title type="html">Transforming Cloud Security: The Shift from Permanent to Just-In-Time Access</title><link href="https://www.occamslabs.com/security/cloud/access/2024/04/30/transforming-cloud-security-the-shift-from-permanent-to-just-in-time-access/" rel="alternate" type="text/html" title="Transforming Cloud Security: The Shift from Permanent to Just-In-Time Access" /><published>2024-04-30T00:00:00+00:00</published><updated>2024-04-30T00:00:00+00:00</updated><id>https://www.occamslabs.com/security/cloud/access/2024/04/30/transforming-cloud-security-the-shift-from-permanent-to-just-in-time-access</id><content type="html" xml:base="https://www.occamslabs.com/security/cloud/access/2024/04/30/transforming-cloud-security-the-shift-from-permanent-to-just-in-time-access/">&lt;p&gt;In the rapidly evolving world of IT, access management has undergone significant transformations. The shift from traditional, always-on access to a more controlled, just-in-time (JIT) access model marks a critical pivot in how businesses handle security in cloud environments.&lt;/p&gt;

&lt;h2 id=&quot;the-era-of-permanent-live-access&quot;&gt;The Era of Permanent Live Access&lt;/h2&gt;

&lt;p&gt;Initially, the norm in many organizations was to grant engineers unfettered access to production systems. This open-door policy, while convenient, often led to unintended consequences. Frequent outages and unauthorized configuration changes bypassing CI/CD pipelines were commonplace, highlighting the risks of excessive access.&lt;/p&gt;

&lt;p&gt;Deployment processes suffered under this regime. What should have been routine updates turned into operational headaches, fraught with delays and disruptions. Moreover, the lax oversight of direct database modifications led to significant disruptions when well-intentioned changes went awry.&lt;/p&gt;

&lt;h2 id=&quot;transition-to-just-in-time-access&quot;&gt;Transition to Just-In-Time Access&lt;/h2&gt;

&lt;p&gt;The turning point came when the unsustainable cost of unregulated access became clear. The transition to just-in-time access was not merely a policy update; it was a foundational shift towards better security practices and operational efficiency.&lt;/p&gt;

&lt;p&gt;This change required a substantial investment in automation technologies and a cultural shift towards trust but verify principles. The deployment processes were streamlined, enabling quicker and more reliable updates with fewer human errors.&lt;/p&gt;

&lt;h2 id=&quot;impacts-of-just-in-time-access&quot;&gt;Impacts of Just-In-Time Access&lt;/h2&gt;

&lt;p&gt;The benefits of JIT access were quickly apparent. Enhanced security protocols and improved administrative tools reduced downtime and minimized the risks associated with human error. An audit trail of all changes ensured accountability and transparency, which are crucial in today’s regulatory environment.&lt;/p&gt;

&lt;p&gt;Administrative tasks were transformed by better tools that provided both efficiency and oversight, making it easier to manage cloud environments securely and effectively.&lt;/p&gt;

&lt;h2 id=&quot;lessons-learned&quot;&gt;Lessons Learned&lt;/h2&gt;

&lt;p&gt;The journey from permanent live access to just-in-time access provided numerous lessons. Most notably, the importance of automation in enhancing security postures and operational capabilities in cloud environments became evident.&lt;/p&gt;

&lt;p&gt;While the transition has dramatically improved security and operational efficiency, it also underscored the ongoing need for innovation in access management.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;The evolution from permanent live access to just-in-time access illustrates a broader trend in cloud security—moving towards systems that not only meet current security demands but also anticipate future challenges. As cloud technologies evolve, so too must our strategies to secure them, ensuring that access is not just managed, but optimized for both security and performance.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;Need help with securing your Cloud Access? Lets chat: &lt;a href=&quot;mailto:andy@occamslabs.com&quot;&gt;andy@occamslabs.com&lt;/a&gt;&lt;/p&gt;</content><author><name>Andreas Tiefenthaler</name><email>contact@occamslabs.com</email></author><category term="security" /><category term="cloud" /><category term="access" /><summary type="html">In the rapidly evolving world of IT, access management has undergone significant transformations. The shift from traditional, always-on access to a more controlled, just-in-time (JIT) access model marks a critical pivot in how businesses handle security in cloud environments.</summary></entry><entry><title type="html">Gone Phishing - Caught Developers</title><link href="https://www.occamslabs.com/security/phishing/2023/10/16/gone-phishing/" rel="alternate" type="text/html" title="Gone Phishing - Caught Developers" /><published>2023-10-16T00:00:00+00:00</published><updated>2023-10-16T00:00:00+00:00</updated><id>https://www.occamslabs.com/security/phishing/2023/10/16/gone-phishing</id><content type="html" xml:base="https://www.occamslabs.com/security/phishing/2023/10/16/gone-phishing/">&lt;p&gt;Phishing attacks are getting more sophisticated by the day. Their target audience is changing every day. In the past, high-profile individuals were targeted using CXO attacks.
These days, the scope has broadened and is targeting the whole organization.&lt;/p&gt;

&lt;p&gt;It is not just a rushed email from your CEO with links to a website that tries to steal your login credentials or make you download malicious software.&lt;/p&gt;

&lt;p&gt;Attackers are getting way more creative to target people and who they are targeting.
Very recently, I encountered an interesting approach to phish a Developer.&lt;/p&gt;

&lt;h2 id=&quot;the-attack&quot;&gt;The Attack&lt;/h2&gt;

&lt;p&gt;The Developer was doing freelance work on the side, which was nothing uncommon. They got a request on a platform to help someone with a problem in a code base. After reviewing and accepting the job, they got access to the repository with instructions on getting it going and what error they would experience.&lt;/p&gt;

&lt;p&gt;The developer went through the Readme, cloned the repo, installed the dependencies, and ran the setup commands. Nothing out of the ordinary and a very common approach. The developer ran into an error, tried a few things to fix it, and eventually dug deeper.&lt;/p&gt;

&lt;p&gt;That’s when they discovered some obfuscated code that would run upon setup. If the developer didn’t use the latest version of the Language, they probably wouldn’t have noticed.&lt;/p&gt;

&lt;p&gt;As they dug deeper into the codebase, they discovered it contained Malware. It would connect to a remote command and control (C2) server and upload the clipboard, browser data, and a lot more. I will go into more detail later.&lt;/p&gt;

&lt;p&gt;The developer immediately took the machine off the network, informed the security team and changed all of their passwords. The blast radius on this was quite big. All credentials this person had access to needed to be rotated. All direct and adjacent systems must be checked for access, abnormal behavior, or anything unusual. It took the team significant time and work to cover all grounds. Which is quite normal with the complexity of things we tend to build.&lt;/p&gt;

&lt;h2 id=&quot;the-reveal&quot;&gt;The Reveal&lt;/h2&gt;

&lt;p&gt;The malicious actor found a very good way to target developers effectively. So effectively that they are operating at a 90% + success ratio. The attackers can make sure the code is run in the best possible environment without needing to scout. Essentially, they can write a full profile of what is required, and their victims come their way 🤯.&lt;/p&gt;

&lt;p&gt;There is no need for fancy zero-day exploits or relying on other weaknesses within the target system. They can even get full root access by asking for it. Everything happens voluntarily and in plain sight.&lt;/p&gt;

&lt;h2 id=&quot;the-shield&quot;&gt;The Shield&lt;/h2&gt;

&lt;p&gt;How do you protect yourself, your team, and your company from this kind of attack?&lt;/p&gt;

&lt;p&gt;Education is the most effective and best prevention. Security always starts with the people. Technology is there to assist and aid them. A person not educated in or willing to follow security principles will not be saved by tooling (for the most part). If you and your teams don’t know how to identify and spot these kinds of threats, it is hard to protect yourself.&lt;/p&gt;

&lt;p&gt;How could this have been avoided?&lt;/p&gt;

&lt;p&gt;First, if something happens, ensure people can bring up when they think they got targeted or even hit by an attack. Do not push them into keeping it a secret by punishing them for wrongdoing. Be kind and empathic; don’t patronize. IT Security is intimidating and scary. Most people do-not like to make mistakes. Even fewer want to have to report that they made a mistake.&lt;/p&gt;

&lt;p&gt;Have clear policies in place. What is allowed and what is not. Is it okay to do freelance work on the side? Can they do it on their workplace computer, or is this a strict no-go? All of this depends on the company, business, the risk appetite, and the culture. There is no one-size-fits-all set of policies.&lt;/p&gt;

&lt;p&gt;It also helps to have some (technical) guardrails in place that protect, prevent, or reduce the impact:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Ensure no admin access to the computers without passwords&lt;/li&gt;
  &lt;li&gt;Use managed browser profiles to ensure passwords are not stored etc.&lt;/li&gt;
  &lt;li&gt;Use single sign-on wherever possible, ensure everyone is using a password manager, and the second factor is not managed in the same password manager.&lt;/li&gt;
  &lt;li&gt;Do not have permanent access to any live system, especially not with privileged accounts.&lt;/li&gt;
  &lt;li&gt;Keep any application secret in a dedicated secret store like HashiCorp Vault etc.&lt;/li&gt;
  &lt;li&gt;Have a good inventory of your secrets. This allows for faster rotation when required.&lt;/li&gt;
  &lt;li&gt;If possible, have some intrusion detection and mobile device management systems in place&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;the-malware&quot;&gt;The Malware&lt;/h2&gt;

&lt;p&gt;What did the malware try to do?&lt;/p&gt;

&lt;p&gt;In this case, it was a 3 part malware. The first part was a JavaScript script hiding in a test runner. It was obfuscated/minimized and hard to reverse engineer. From what we identified, it tried to contact a command and control server to download further instructions and invoke the second and third parts of the malware written in Python.&lt;/p&gt;

&lt;p&gt;The second script would:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Grab the contents of the clipboard.&lt;/li&gt;
  &lt;li&gt;Get the browser history, sessions, and stored data (form and passwords).&lt;/li&gt;
  &lt;li&gt;Look for password files, SSH keys, keyrings, and all kinds of files.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And upload all these files to a C2 server.&lt;/p&gt;

&lt;p&gt;The third script would establish itself within the system for later use. All 3 scripts talked to different C2 servers.&lt;/p&gt;

&lt;p&gt;The codebase was based on an open-source tooling that was modified. Variations of this attack can be found on GitHub in plain sight.&lt;/p&gt;

&lt;h2 id=&quot;the-tldr&quot;&gt;The TL;DR&lt;/h2&gt;

&lt;p&gt;A developer got tricked into cloning some code that included malware to steal credentials, crypto wallets, and more. They did the right thing to take the machine offline and inform their security team. The most important thing to prevent attacks like this to educate and teach your team, set out policies to prevent them, and put the right tooling into place to do damage control.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;Need help with securing your Kubernetes deployments? Lets chat: &lt;a href=&quot;mailto:andy@occamslabs.com&quot;&gt;andy@occamslabs.com&lt;/a&gt;&lt;/p&gt;</content><author><name>Andreas Tiefenthaler</name><email>contact@occamslabs.com</email></author><category term="security" /><category term="phishing" /><summary type="html">Phishing attacks are getting more sophisticated by the day. Their target audience is changing every day. In the past, high-profile individuals were targeted using CXO attacks. These days, the scope has broadened and is targeting the whole organization.</summary></entry><entry><title type="html">You are doing it wrong! Kubernetes Image Tags</title><link href="https://www.occamslabs.com/supplychain/security/kubernetes/2023/09/15/you-are-doing-it-wrong-kubernetes-image-tags/" rel="alternate" type="text/html" title="You are doing it wrong! Kubernetes Image Tags" /><published>2023-09-15T00:00:00+00:00</published><updated>2023-09-15T00:00:00+00:00</updated><id>https://www.occamslabs.com/supplychain/security/kubernetes/2023/09/15/you-are-doing-it-wrong-kubernetes-image-tags</id><content type="html" xml:base="https://www.occamslabs.com/supplychain/security/kubernetes/2023/09/15/you-are-doing-it-wrong-kubernetes-image-tags/">&lt;p&gt;How you are using Docker tags can say a lot about your security.&lt;/p&gt;

&lt;h2 id=&quot;you-are-using-the-latest-tag&quot;&gt;You are using the latest tag!&lt;/h2&gt;

&lt;p&gt;(scroll down for a 5-sentence summary)&lt;/p&gt;

&lt;p&gt;You are using the latest tag. We have all been there, and this is the most convenient way. There is no need to update anything. Just restart the pod. Building and pushing the image is also a breeze, with absolutely zero logic needed. This might be okay for a continuously rolled-out development cluster. You shouldn’t use this anywhere else, though. How do you know exactly what is deployed at the moment? How do you do a rollback? Essentially, you are not in control; you pull whatever is there at any time. There is a time and a place for using this, and your deployments aren’t one of them. Good luck, you will need it.&lt;/p&gt;

&lt;p&gt;So, you are using image tags like v1.2.3. This is great for humans to know what we are talking about. And it is better than using the latest tag. But it’s still wrong. Tags are mere bookmarks of changes at a certain point in time. Anyone with access can move around them, and they are not immutable. With proper tags, you can have better conversations about deployment issues. You can do more efficient rollbacks for most parts. You still can not trust that what you are deploying right now is the same as when you deployed it the first time. This is a big risk, especially for third-party services.&lt;/p&gt;

&lt;p&gt;What is the correct way to deploy container images in Kubernetes?&lt;/p&gt;

&lt;p&gt;You have to use the SHA256 of the images for enhanced security and accuracy. The latest tags, or any other tag, are mutable. They are a bookmark to a certain SHA256. The only way to be certain about what you are deploying is by using the cryptographic hash. The SHA256 is the cryptographic digest of the image with all layers included.&lt;/p&gt;

&lt;p&gt;Bonus points if the image is signed by &lt;a href=&quot;https://docs.docker.com/engine/security/trust/&quot;&gt;docker content trust&lt;/a&gt; or &lt;a href=&quot;https://docs.sigstore.dev/signing/quickstart/&quot;&gt;cosign&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The easiest way to get the hash of any image:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
  docker inspect --format='{{index .RepoDigests 0}}' $IMAGE


&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Should you use the hashes also for deployments of third-party services? This is particularly important. You don’t control the third-party repository, and you want to maximize the control you have. Changing the deployed version to the deployed hash will give you confidence.&lt;/p&gt;

&lt;h2 id=&quot;summary&quot;&gt;Summary&lt;/h2&gt;

&lt;p&gt;When doing Kubernetes image deployments, using tags like “latest” or version numbers such as “v1.2.3” can pose problems related to version control and security. To address this, consider using the SHA256 hash of images for deployment. This method ensures immutability and accuracy, and I recommend signing images using tools like Docker Content Trust or Cosign to enhance security. This approach is especially valuable when dealing with third-party services, granting you better control and confidence in your Kubernetes deployments.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;Need help with securing your Kubernetes deployments? Lets chat: &lt;a href=&quot;mailto:andy@occamslabs.com&quot;&gt;andy@occamslabs.com&lt;/a&gt;&lt;/p&gt;</content><author><name>Andreas Tiefenthaler</name><email>contact@occamslabs.com</email></author><category term="supplychain" /><category term="security" /><category term="kubernetes" /><summary type="html">How you are using Docker tags can say a lot about your security.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://www.occamslabs.com/clean.jpg" /><media:content medium="image" url="https://www.occamslabs.com/clean.jpg" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Securing Kubernetes Workloads with Enhanced Supply Chain Security</title><link href="https://www.occamslabs.com/supplychain/security/kubernetes/2023/08/11/securing-kubernetes-workloads/" rel="alternate" type="text/html" title="Securing Kubernetes Workloads with Enhanced Supply Chain Security" /><published>2023-08-11T00:00:00+00:00</published><updated>2023-08-11T00:00:00+00:00</updated><id>https://www.occamslabs.com/supplychain/security/kubernetes/2023/08/11/securing-kubernetes-workloads</id><content type="html" xml:base="https://www.occamslabs.com/supplychain/security/kubernetes/2023/08/11/securing-kubernetes-workloads/">&lt;p&gt;In today’s rapidly evolving tech environment, securing your Kubernetes workloads has never been more crucial. As Kubernetes becomes the backbone of many IT infrastructures, implementing robust Kubernetes supply chain security measures is essential to safeguard against vulnerabilities and threats.&lt;/p&gt;

&lt;h2 id=&quot;understanding-kubernetes-supply-chain-risks&quot;&gt;Understanding Kubernetes Supply Chain Risks&lt;/h2&gt;

&lt;p&gt;Kubernetes environments are complex and can be vulnerable to various supply chain risks. These risks often stem from insufficiently secured artifacts or unauthorized access to the supply chain. To combat these vulnerabilities, Kubernetes supply chain policy management must be a top priority for organizations looking to protect their assets.&lt;/p&gt;

&lt;h2 id=&quot;strategies-for-kubernetes-supply-chain-security&quot;&gt;Strategies for Kubernetes Supply Chain Security&lt;/h2&gt;

&lt;p&gt;Enhancing the security of your Kubernetes supply chain involves several strategic steps. Here are the key strategies to implement:&lt;/p&gt;

&lt;h3 id=&quot;1-comprehensive-policy-management&quot;&gt;1. Comprehensive Policy Management&lt;/h3&gt;
&lt;p&gt;Implementing comprehensive Kubernetes supply chain policy management practices is vital. This involves defining and enforcing policies that govern the security and compliance of all software artifacts. By using tools like policy as code and real-time enforcement mechanisms, organizations can ensure that only verified and authorized components are used within their environments.&lt;/p&gt;

&lt;h3 id=&quot;2-employing-continuous-security-practices&quot;&gt;2. Employing Continuous Security Practices&lt;/h3&gt;
&lt;p&gt;Continuous integration and continuous deployment (CI/CD) pipelines are integral to Kubernetes environments. Incorporating security checks throughout these pipelines enhances Kubernetes supply chain security by detecting vulnerabilities early in the development process.&lt;/p&gt;

&lt;h3 id=&quot;3-regular-audits-and-compliance-checks&quot;&gt;3. Regular Audits and Compliance Checks&lt;/h3&gt;
&lt;p&gt;Regular audits are crucial for maintaining a secure supply chain. These audits help identify any discrepancies or vulnerabilities in your Kubernetes deployments. Additionally, compliance checks ensure that your supply chain adheres to industry standards and regulatory requirements, strengthening your overall security posture.&lt;/p&gt;

&lt;p&gt;Tools like &lt;a href=&quot;https://github.com/aquasecurity/trivy-operator&quot;&gt;Trivy operator&lt;/a&gt; and &lt;a href=&quot;https://quay.github.io/clair/&quot;&gt;Clair&lt;/a&gt; can support this. They are regularly scanning your running containers and will emit alerts for you. This adds extra load to your system but allows for the most accurate representation of vulnerabilities in your clusters.&lt;/p&gt;

&lt;h3 id=&quot;4-utilizing-secure-containers-and-artifacts&quot;&gt;4. Utilizing Secure Containers and Artifacts&lt;/h3&gt;
&lt;p&gt;The use of secure and trusted containers and artifacts is fundamental. Ensuring that your containers are sourced from reputable registries and are signed can significantly mitigate the risk of introducing vulnerabilities into your Kubernetes environment. &lt;a href=&quot;https://docs.docker.com/engine/security/trust/&quot;&gt;Docker Content Trust&lt;/a&gt; and &lt;a href=&quot;https://github.com/sigstore/cosign&quot;&gt;Cosign&lt;/a&gt; by &lt;a href=&quot;https://www.sigstore.dev/&quot;&gt;sigstore&lt;/a&gt; are currently the best supported.&lt;/p&gt;

&lt;p&gt;We have a introduction to &lt;a href=&quot;/kb/kubernetes-security-101/&quot;&gt;K8S security&lt;/a&gt; if you want to know more.&lt;/p&gt;

&lt;p&gt;Need help with securing your Kubernetes deployments? Lets chat: &lt;a href=&quot;mailto:andy@occamslabs.com&quot;&gt;andy@occamslabs.com&lt;/a&gt;&lt;/p&gt;</content><author><name>Andreas Tiefenthaler</name><email>contact@occamslabs.com</email></author><category term="supplychain" /><category term="security" /><category term="kubernetes" /><summary type="html">In today’s rapidly evolving tech environment, securing your Kubernetes workloads has never been more crucial. As Kubernetes becomes the backbone of many IT infrastructures, implementing robust Kubernetes supply chain security measures is essential to safeguard against vulnerabilities and threats.</summary></entry><entry><title type="html">Vulnerability vs. Supply Chain Attack</title><link href="https://www.occamslabs.com/supplychain/security/2023/08/07/vulnerability-vs-supply-chain-attack/" rel="alternate" type="text/html" title="Vulnerability vs. Supply Chain Attack" /><published>2023-08-07T00:00:00+00:00</published><updated>2023-08-07T00:00:00+00:00</updated><id>https://www.occamslabs.com/supplychain/security/2023/08/07/vulnerability-vs-supply-chain-attack</id><content type="html" xml:base="https://www.occamslabs.com/supplychain/security/2023/08/07/vulnerability-vs-supply-chain-attack/">&lt;p&gt;A &lt;strong&gt;vulnerability&lt;/strong&gt; is usually an unintended software bug that opens an attack angle for a malicious actor. The good thing about an open-source project is, that the bigger the project, the more eyes are on it. The more likely these vulnerabilities will surface and be fixed fast. In smaller or dormant projects, this is usually not the case.&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;supply chain attack&lt;/strong&gt; is a deliberately created attack against a language ecosystem or certain users.&lt;/p&gt;

&lt;p&gt;Recently, very targeted attacks have been seen against the fintech sector.&lt;/p&gt;

&lt;p&gt;The attackers would use various different techniques to spread the malicious code. From simple typo squatting - where you publish a new package with a common spelling mistake - to sophisticated attacks - where social media profiles are created to build trust with the community and victims - the range is wide.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How can you protect your applications from either?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As discussed last week, lockfiles are an essential part of detecting attacks. There is more that can be done. A variety of open-source and commercial projects review the required dependencies. Then they compare the versions with various data sources to identify if you have a vulnerability in your dependencies.&lt;/p&gt;

&lt;p&gt;Make these tools part of your workflow. Add them:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;your Local development&lt;/li&gt;
  &lt;li&gt;the CI/CD pipelines for every merge request,&lt;/li&gt;
  &lt;li&gt;running in your live systems to detect new vulnerabilities that are actively in use.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These exact tools also help you identify known vulnerabilities in your dependencies.&lt;/p&gt;

&lt;p&gt;The moment you enable tools like this, the chance is high to get a lot of findings as a result.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to triage vulnerable dependencies&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Scanning for vulnerabilities can lead to many results. How to tame the findings and get actionable?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step one:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;Filter all findings by the highest severity&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Review each finding with the questions in step two&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step two, review each finding:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;What is the potential impact&lt;/li&gt;
  &lt;li&gt;Can it be used by external attackers?&lt;/li&gt;
  &lt;li&gt;How complicated is it to be executed?&lt;/li&gt;
  &lt;li&gt;Is the code in use? (not easy sometimes)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 3:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Create a ticket with severity and questions/answers of the assessment&lt;/li&gt;
  &lt;li&gt;Include the version that is secure&lt;/li&gt;
  &lt;li&gt;Reduce the severity of the finding if needed.&lt;/li&gt;
  &lt;li&gt;Add an expectation until when this should be fixed (internal SLA)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What do you think? Let me know at &lt;a href=&quot;mailto:andy@occamslabs.com&quot;&gt;andy@occamslabs.com&lt;/a&gt;&lt;/p&gt;</content><author><name>Andreas Tiefenthaler</name><email>contact@occamslabs.com</email></author><category term="supplychain" /><category term="security" /><summary type="html">A vulnerability is usually an unintended software bug that opens an attack angle for a malicious actor. The good thing about an open-source project is, that the bigger the project, the more eyes are on it. The more likely these vulnerabilities will surface and be fixed fast. In smaller or dormant projects, this is usually not the case.</summary></entry><entry><title type="html">Supply Chains and Lock Files</title><link href="https://www.occamslabs.com/supplychain/security/2023/08/01/supply-chains-and-lock-files/" rel="alternate" type="text/html" title="Supply Chains and Lock Files" /><published>2023-08-01T00:00:00+00:00</published><updated>2023-08-01T00:00:00+00:00</updated><id>https://www.occamslabs.com/supplychain/security/2023/08/01/supply-chains-and-lock-files</id><content type="html" xml:base="https://www.occamslabs.com/supplychain/security/2023/08/01/supply-chains-and-lock-files/">&lt;p&gt;A supply chain attack is when one or more of the dependencies in your application have been compromised, and some “bad code “is running on your systems and applications that is intended to harm you. These kinds of attacks are becoming more common and more sophisticated.&lt;/p&gt;

&lt;p&gt;Most programming environments that offer a form of dependency manager have a locking mechanism in place. The manager allows to specify what kind of version should is used. And stores the version along with a checksum/cryptographic hash in a sometimes-called lockfile.&lt;/p&gt;

&lt;p&gt;These lockfiles are essential to keeping applications safe from supply chain attacks. If the remote code changes but the same version number is used, you will get a checksum mismatch.&lt;/p&gt;

&lt;p&gt;No matter if you update dependencies by hand or use tools like Dependabot or Renovate. You must review the changes to ensure the functionality is as you expect and the new code does not introduce any malware or obvious bad intentions. Simply updating and not checking is dangerous and circumvents the whole system.&lt;/p&gt;

&lt;p&gt;How do you spot bad” intentions? Some ideas:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;the change introduces a new dependency,&lt;/li&gt;
  &lt;li&gt;changes to pre/post-install hooks of the dependency manager,&lt;/li&gt;
  &lt;li&gt;introduces cryptic code that is unclear&lt;/li&gt;
  &lt;li&gt;downloads stuff from the internet all of a sudden.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;How often should you update your dependencies?&lt;/p&gt;

&lt;p&gt;There are two strong opposing approaches to updating software and dependencies.&lt;/p&gt;

&lt;p&gt;The first approach you constantly update everything to stay on the bleeding edge. The second one is you update only when there is a necessity. Otherwise, never touch it.&lt;/p&gt;

&lt;p&gt;What is the best way?&lt;/p&gt;

&lt;p&gt;It depends on the environment and the company, how many people how many systems and moving parts they have. A good rule of thumb is to keep things up to date “enough,” so it is easy to get it done during an emergency security update. You don’t need to spend days or weeks fixing stuff.&lt;/p&gt;

&lt;p&gt;What do you think? Let me know at &lt;a href=&quot;mailto:andy@occamslabs.com&quot;&gt;andy@occamslabs.com&lt;/a&gt;&lt;/p&gt;</content><author><name>Andreas Tiefenthaler</name><email>contact@occamslabs.com</email></author><category term="supplychain" /><category term="security" /><summary type="html">A supply chain attack is when one or more of the dependencies in your application have been compromised, and some “bad code “is running on your systems and applications that is intended to harm you. These kinds of attacks are becoming more common and more sophisticated.</summary></entry><entry><title type="html">Securing your Ruby and Rails Codebase</title><link href="https://www.occamslabs.com/ruby-on-rails/security/devsecops/2018/09/24/securing-your-ruby-and-rails-codebase/" rel="alternate" type="text/html" title="Securing your Ruby and Rails Codebase" /><published>2018-09-24T00:00:00+00:00</published><updated>2018-09-24T00:00:00+00:00</updated><id>https://www.occamslabs.com/ruby-on-rails/security/devsecops/2018/09/24/securing-your-ruby-and-rails-codebase</id><content type="html" xml:base="https://www.occamslabs.com/ruby-on-rails/security/devsecops/2018/09/24/securing-your-ruby-and-rails-codebase/">&lt;p&gt;When writing software you want to avoid introducing functional bugs or security issues.&lt;/p&gt;

&lt;p&gt;For functional bugs, we usually write unit tests and try to cover edge cases. Integration tests then make sure that things work together.&lt;/p&gt;

&lt;p&gt;In this article, we will walk through how we can secure a Ruby, Rails, or Rack-based app.&lt;/p&gt;

&lt;p&gt;No matter if it is a new codebase, or we are adding it to a 10-year-old project, in the end we will have a decent level of security testing.&lt;/p&gt;

&lt;p&gt;For this article we will be using open-source software tools to secure our codebase. We will also consider some hosted and already configured alternatives.&lt;/p&gt;

&lt;p&gt;Our toolbox:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;bundler-audit&lt;/li&gt;
  &lt;li&gt;brakeman&lt;/li&gt;
  &lt;li&gt;rubocop (has some security rules)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The tools can be categorized into Static Application Security Testing (SAST) and Software Composition Analysis (SCA) tools.&lt;/p&gt;

&lt;p&gt;Static analysis scans your codebase and looks for certain kinds of patterns. It will not execute your code and cannot detect problems in generated code, or at runtime.&lt;/p&gt;

&lt;p&gt;The results will usually show the line of code the issue is detected. They will also alert you to the type of issue identified (with a severity), and sometimes an advisory on how to fix the problem.&lt;/p&gt;

&lt;p&gt;In contrast, software composition analysis will check the dependencies you are using for vulnerabilities.&lt;/p&gt;

&lt;p&gt;The report usually includes:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The package name of the affected dependency.&lt;/li&gt;
  &lt;li&gt;Severity on how bad it is. This usually spans from none to critical.&lt;/li&gt;
  &lt;li&gt;The next safe version to upgrade to.&lt;/li&gt;
  &lt;li&gt;Some more references that explain what the problem is and more details.&lt;/li&gt;
  &lt;li&gt;In some cases an identifier that leads to a vulnerability database.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To run the security tools, you do not need a CI pipeline but it is generally recommended to have one in place.
We will install the tools in a ruby/rails project. You will also learn how to enable the rake tasks and run them.
All the tools also have normal executables and can be used one by one, or in a shell script.&lt;/p&gt;

&lt;h2 id=&quot;bundler-audit&quot;&gt;Bundler Audit&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/rubysec/bundler-audit&quot;&gt;Bundler Audit&lt;/a&gt; will detect vulnerable dependencies in your codebase.&lt;/p&gt;

&lt;p&gt;First, add the bundler-audit gem to your Gemfile:&lt;/p&gt;
&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'bundler-audit'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;and install your bundle.&lt;/p&gt;

&lt;p&gt;Now you can run a&lt;/p&gt;
&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;bundle&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;audit&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;check&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;update&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This will update the local database first, and then check your project for vulnerable dependencies.&lt;/p&gt;

&lt;p&gt;Keep in mind that bundle audit does not update the dependencies automatically. I recommend you to always update them before each run to ensure you get the best and most up-to-date results.&lt;/p&gt;

&lt;p&gt;To enable the rake tasks, add the following to your project Rakefile:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'bundler/audit/task'&lt;/span&gt;
&lt;span class=&quot;no&quot;&gt;Bundler&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;Audit&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;Task&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;new&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;A &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rake bundle:audit&lt;/code&gt; will now update the data and perform the checks.&lt;/p&gt;

&lt;p&gt;If you found any vulnerabilities at this point do not freak out. You can look into fixing them by updating the version to the next safe one.&lt;/p&gt;

&lt;p&gt;In case you can not update, you can use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--ignore $vulnerability-id&lt;/code&gt; to suppress it for now.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;
&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;bundle&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;audit&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;check&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;update&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ignore&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;OSVDB&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;108664&lt;/span&gt;
&lt;span class=&quot;no&quot;&gt;The&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;looks&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;something&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;like&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;this:

&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;$&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bundle&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;audit&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;check&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;update&lt;/span&gt;

&lt;span class=&quot;no&quot;&gt;Updating&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ruby&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;advisory&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;db&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;...&lt;/span&gt;
&lt;span class=&quot;no&quot;&gt;From&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;https&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:/&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;github&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;com&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rubysec&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ruby&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;advisory&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;db&lt;/span&gt;
 &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;branch&lt;/span&gt;            &lt;span class=&quot;n&quot;&gt;master&lt;/span&gt;     &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;FETCH_HEAD&lt;/span&gt;
&lt;span class=&quot;no&quot;&gt;Already&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;up&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;to&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;
&lt;span class=&quot;no&quot;&gt;Updated&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ruby&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;advisory&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;db&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;ruby&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;advisory&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;db: &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;322&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;advisories&lt;/span&gt;
&lt;span class=&quot;no&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;omniauth&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;oauth2&lt;/span&gt;
&lt;span class=&quot;no&quot;&gt;Version&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;1.0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;
&lt;span class=&quot;no&quot;&gt;Advisory&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;CVE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2012&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;6134&lt;/span&gt;
&lt;span class=&quot;no&quot;&gt;Criticality&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;High&lt;/span&gt;
&lt;span class=&quot;no&quot;&gt;URL&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;http&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:/&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;www&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;osvdb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;org&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;osvdb&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;90264&lt;/span&gt;
&lt;span class=&quot;no&quot;&gt;Title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Ruby&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;on&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Rails&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;omniauth&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;oauth2&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Gem&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;CSRF&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;vulnerability&lt;/span&gt;
&lt;span class=&quot;no&quot;&gt;Solution&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;upgrade&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;to&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;=&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;1.1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;

&lt;span class=&quot;no&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rubyzip&lt;/span&gt;
&lt;span class=&quot;no&quot;&gt;Version&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;1.2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;
&lt;span class=&quot;no&quot;&gt;Advisory&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;CVE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2018&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1000544&lt;/span&gt;
&lt;span class=&quot;no&quot;&gt;Criticality&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Unknown&lt;/span&gt;
&lt;span class=&quot;no&quot;&gt;URL&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;https&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:/&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;github&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;com&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rubyzip&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rubyzip&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;issues&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;369&lt;/span&gt;
&lt;span class=&quot;no&quot;&gt;Title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Directory&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Traversal&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rubyzip&lt;/span&gt;
&lt;span class=&quot;no&quot;&gt;Solution&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;upgrade&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;to&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;=&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;1.2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;

&lt;span class=&quot;no&quot;&gt;Vulnerabilities&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;found!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;##Brakeman##&lt;/p&gt;

&lt;p&gt;Next, we will add &lt;a href=&quot;https://github.com/presidentbeef/brakeman&quot;&gt;Brakeman&lt;/a&gt; as our first static code analysis tool. Brakeman will look for known insecure patterns and configurations in your code base. It will also check if you are using a known vulnerable rails version.&lt;/p&gt;

&lt;p&gt;Brakeman works not only for Rails, but it also covers Sinatra and any kind of rack application.&lt;/p&gt;

&lt;p&gt;First, add the dependency to your Gemfile:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;brakeman&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;and install it:&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bundle &lt;span class=&quot;nb&quot;&gt;install&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Then you can run it for the first time in your rails root directory.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;brakeman
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This will invoke Brakeman and output some lengthy report. Here is a gist with a sample report: &lt;a href=&quot;https://gist.github.com/pxlpnk/4a829b6101abe5fc0102d358d8dd028d&quot;&gt;link to a gist&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If your app is safe and you get no findings run it, first of all good job!&lt;/p&gt;

&lt;p&gt;But then you want to see how it looks like, so you can try it with OWASP/RailsGoat.&lt;/p&gt;

&lt;p&gt;If you run Brakeman for the first time on any older Rails application you might get a lot of findings.&lt;/p&gt;

&lt;p&gt;To make things easier, you want to start with more severe issues and work down to the less critical ones.&lt;/p&gt;

&lt;p&gt;To do so, use brakeman &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-w3&lt;/code&gt; and it will show only high, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-w2&lt;/code&gt; will show high and medium, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-w1&lt;/code&gt; will show all other findings.&lt;/p&gt;

&lt;p&gt;Approaching it level-by-level usually works the best and is the most efficient.&lt;/p&gt;

&lt;p&gt;If you plan to use rake, you can install the RakeTask very easily.&lt;/p&gt;

&lt;p&gt;Running a&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;brakeman &lt;span class=&quot;nt&quot;&gt;--rake&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;will create a task file in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;lib/tasks/brakeman.rake&lt;/code&gt; which can be run with:&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;rake brakeman:run
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;To customize it and use more advanced options see the documentation brakeman as a library.&lt;/p&gt;

&lt;h2 id=&quot;rubocop&quot;&gt;RuboCop&lt;/h2&gt;

&lt;p&gt;While &lt;a href=&quot;https://github.com/rubocop-hq/rubocop&quot;&gt;rubocop&lt;/a&gt; is known as a linter and formatter, it comes with some security rules and can be extended with some community extensions.&lt;/p&gt;

&lt;p&gt;Let us get started with installing RuboCop first. Add the following to your Gemfile:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'rubocop'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;require: &lt;/span&gt;&lt;span class=&quot;kp&quot;&gt;false&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Then run our old friend&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bundle &lt;span class=&quot;nb&quot;&gt;install&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Once this has finished, you can execute the rubocop command.&lt;/p&gt;

&lt;p&gt;If you have not used rubocop before you might see a lot of output and warnings printed out in your terminal.&lt;/p&gt;

&lt;p&gt;For this post, we are not so much interested in the linting and formatting rules. Instead we make sure we only run the security relevant rules.&lt;/p&gt;

&lt;p&gt;We will be using the following .rubocop.yml configuration to start out.&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;na&quot;&gt;AllCops&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;DisabledByDefault&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;true&lt;/span&gt;

&lt;span class=&quot;na&quot;&gt;Security/Eval&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Enabled&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Security/JSONLoad&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Enabled&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Security/MarshalLoad&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Enabled&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Security/Open&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Enabled&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Security/YAMLLoad&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Enabled&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Bundler/InsecureProtocolSource&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Enabled&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Rails/OutputSafety&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Enabled&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We are disabling all the style and linting rules, and enabling only security-relevant ones. This is only done for simplicity in this blog post.&lt;/p&gt;

&lt;p&gt;Running the rubocop command now should be way less noisy.&lt;/p&gt;

&lt;p&gt;This is how it looks like on the RailsGoat repository:&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;bundlex &lt;span class=&quot;nb&quot;&gt;exec &lt;/span&gt;rubocop

Inspecting 121 files
............C....................
Offenses:

app/controllers/password_resets_controller.rb:6:20: C: Security/MarshalLoad: Avoid using Marshal.load.
    user &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; Marshal.load&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;Base64.decode64&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;params[:user]&lt;span class=&quot;o&quot;&gt;))&lt;/span&gt; unless params[:user].nil?
                   ^^^^

121 files inspected, 1 offense detected
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Not too impressive yet, but we are getting some relevant security info already.&lt;/p&gt;

&lt;p&gt;Now we will add some more security rules.&lt;/p&gt;

&lt;p&gt;Add the following to your Gemfile: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gem 'rubocop-gitlab-security'&lt;/code&gt; and run ``bundle install` again.&lt;/p&gt;

&lt;p&gt;Now add the following to the configuration file &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rubycop.yml&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;na&quot;&gt;GitlabSecurity/DeepMunge&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Enabled&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;GitlabSecurity/JsonSerialization&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Enabled&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;GitlabSecurity/RedirectToParamsUpdate&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Enabled&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;GitlabSecurity/SendFileParams&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Enabled&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;GitlabSecurity/SqlInjection&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Enabled&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;GitlabSecurity/SystemCommandInjection&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Enabled&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Those curated rules by the GitLab team add tremendous value to our security setup.&lt;/p&gt;

&lt;p&gt;Now we need to require the new modules when running RuboCop:&lt;/p&gt;

&lt;p&gt;Either by running:&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bundle exec rubocop --require rubocop-gitlab-security &lt;/code&gt;&lt;/p&gt;

&lt;p&gt;or add this to the rubocop.yml:&lt;/p&gt;
&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;na&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;rubocop-gitlab-security&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;We can now find more security problems in the RailsGoat repository. Here is a gist with a sample report:https://gist.github.com/pxlpnk/958c500aab22f90b54918d6d9573251d&lt;/p&gt;

&lt;p&gt;To configure the RakeTasks add:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'rubocop/rake_task'&lt;/span&gt;
&lt;span class=&quot;no&quot;&gt;RuboCop&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;RakeTask&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;task&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;task&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;requires&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'rubocop-gitlab-security'&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;to your RakeFile and run it: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rake rubocop&lt;/code&gt;&lt;/p&gt;

&lt;h2 id=&quot;fixing-findings&quot;&gt;Fixing Findings&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;To not drown in findings I recommend you configure and enable one scanner at a time.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Start with high severity findings and filter out the rest.&lt;/p&gt;

&lt;p&gt;Some of the results will be false positives or are no danger at all for various reasons. They can usually be ignored and added to a list to not be noisy.&lt;/p&gt;

&lt;p&gt;Once you have fixed or muted the findings and it behaves as you would like, move on to the next one.&lt;/p&gt;

&lt;p&gt;When you have reached the point that you feel happy and comfortable with your setup, enable these tools to fail your CI builds and run them on every code change you commit.&lt;/p&gt;

&lt;p&gt;Now you will always know when something is not up to your security standards.&lt;/p&gt;

&lt;h2 id=&quot;open-source-security-tools-are-great&quot;&gt;Open Source Security Tools are Great&lt;/h2&gt;

&lt;p&gt;The ruby community has put massive effort into creating those tools. They are free for everyone to use and should be supported!&lt;/p&gt;

&lt;p&gt;If you can afford it, send them some money or other support so they can continue and improve the tools in the future.&lt;/p&gt;

&lt;p&gt;What do you think? Let me know at &lt;a href=&quot;mailto:andy@occamslabs.com&quot;&gt;andy@occamslabs.com&lt;/a&gt;&lt;/p&gt;</content><author><name>Andreas Tiefenthaler</name><email>contact@occamslabs.com</email></author><category term="ruby-on-rails" /><category term="security" /><category term="devsecops" /><summary type="html">When writing software you want to avoid introducing functional bugs or security issues.</summary></entry></feed>