Skip to content

Update templates main #2504

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 1, 2025
Merged

Update templates main #2504

merged 2 commits into from
Feb 1, 2025

Conversation

varunsh-coder
Copy link
Member

No description provided.

Copy link
Contributor

@step-security-bot step-security-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please find StepSecurity AI-CodeWise code comments below.

Code Comments

testfiles/secureworkflow/output/nopin.yml

  • [High]Provide a description for the egress-policy
    The egress-policy is not sufficiently descriptive. Change:
    egress-policy: audit
    to:
    egress-policy: audit all outbound network calls
  • [Low]Use a more specific version tag when using a GitHub action
    Using a non-specific version tag in a GitHub action makes the build susceptible to breaking changes if the action is modified in the future. Change:
    uses: step-security/harden-runner@v2
    to:
    uses: step-security/[email protected]

workflow-templates/scorecards.yml

  • [High]Update dependencies on a verified repository
    The 'uses' field references an external dependency from an unspecified repository. It is recommended to only use verified dependencies from trustworthy sources, like those that are provided by the open-source community and are managed through their own libraries. Change the 'uses' field to point to a verified dependency repository, possibly one that is hosted on an open-source community like GitHub or npm.
  • [Medium]Avoid using specific commit refs for dependencies
    The 'uses' field references a specific commit ref of the 'ossf/scorecard-action' library instead of a tagged release. This makes it possible to have unintended consequences for the overall operation of the system like security vulnerabilities resulting from using an outdated, untested or unsupported version of a library. Replace the specific commit ref with a tagged release version that is confirmed to be secure and up-to-date.
  • [Medium]Enable permission for writing credentials
    The configuration explicitly disables writing credentials, which can be necessary for the build and deployment processes in the future. Enable permission for writing credentials by changing 'persist-credentials: false' to 'persist-credentials: true' in the configuration.

remediation/workflow/hardenrunner/addaction.go

  • [High]Avoid using hardcoded sensitive strings in code
    The string 'step-security/harden-runner' is hardcoded in the code. This is a security concern as an attacker who can access the code can easily identify the sensitive resource path. It is recommended to store such sensitive strings in a configuration file or environment variables. Create a configuration file or environment variable to store the sensitive string. Replace the hardcoded string with the value from the configuration file or environment variables.
  • [Medium]Use constant time comparison for sensitive data
    The '==' operator is used to compare strings, which is not a constant time comparison method. This can lead to timing attacks as an attacker can use the timing information to extract sensitive data. It is recommended to use constant time comparison functions like crypto/subtle.ConstantTimeCompare to compare sensitive data. Replace the '==' operator with a constant time comparison function like crypto/subtle.ConstantTimeCompare.
  • [Medium]Conduct Compiler Security Reviews
    Even though the code is written with the correct security principles, the source code contains sensitive data, which is only obfuscated sub-optimally. Compilers may optimize code and introduce security vulnerabilities. It is recommended to conduct compiler security reviews to identify and eliminate any such vulnerabilities. Conduct Compiler Security Reviews for the relevant code to identify and eliminate vulnerabilities. If sensitive data must be included, it must be obfuscated using an appropriate algorithm.
  • [Medium]Enforce Strict Arithmetic Operations
    The '==' operator is used to compare two constant values. This implies that arithmetic operations in the Code can be imprecise leading to errors in the system. It is recommended to enforce strict arithmetic operations to avoid errors in the system. Instead of using the '==' operator for comparison, use strict arithmetic operations to avoid errors in the system.
  • [Low]Avoid Single Line If/Else statements
    Single line if/else statements can lead to confusion and make the Code less maintainable. A single line if/else can also lead to readability concerns as neither CodeBlock encompassing the If statement nor the Else statement is specified. It is recommended to avoid using Single Line If/else statements where possible. Rewrite Single Line If/Else statements to a multiline statement to improve the readability and maintainability of the code.

testfiles/addaction/output/2jobs.yml

  • [High]Use unique names for each job
    There are two jobs with the same name 'list-directory'. This can cause confusion and possible errors in the future. Rename one of the jobs to a unique name.
  • [Medium]Use descriptive step names
    Steps should be named with a clear and descriptive action to make the workflow easier to follow. Replace 'Harden Runner' with 'Harden the runner (Audit all outbound calls)'
  • [Low]Add comments to describe job purpose
    Adding comments to describe the purpose of each job can help future maintainers understand the purpose of the step. Add a comment on each job to describe its purpose.

testfiles/addaction/output/action-issues.yml

  • [High]Follow the Principle of Least Privilege and minimize the runner permissions
    The current runner configuration applies a liberal outbound network egress-control policy. This may increase the attack surface of the runner instance. Limit the permissions of the runner by making use of a firewall, VPC, or network security group to restrict outbound egress traffic. In addition, audit the calls and enforce policies for alerting on any suspicious activity.
  • [Medium]Enforce a security policy on the runner
    There is no security policy enforced at the runner level. This may allow malicious actors to exploit the runner's vulnerabilities and elevate privileges on the host. Enforce security policies on both the runner and the host level to identify potential vulnerabilities, reduce the attack surface and provide security measures to prevent exploits. One way to achieve this is by embedding security checks as part of your CI/CD pipeline.
  • [Medium]Ensure Up-to-date Runners
    The runner being used may have vulnerabilities or outdated software, which can allow for exploits or security gaps in the future. Ensure that the runner being used is updated regularly, security patches are up-to-date and any open-source dependencies are also patched or updated. Use automated tools which conduct vulnerability scanning of runners for an early indication of the vulnerabilities that need attention.

testfiles/addaction/output/alreadypresent.yml

  • [High]Use a specific version for the action being used or lock version range down to known working versions
    The action 'step-security/harden-runner@v2' is being used without any version constraint. This can break the reliability of the pipeline if the underlying action changes. Use a specific version to lock the action to a known working version or define a valid version range that works with the current workflow. For example, if v2.0.0 is a known working version then replace 'step-security/harden-runner@v2' with 'step-security/[email protected]'
  • [Low]Use meaningful names for all pipeline steps
    The step 'Harden the runner (Audit all outbound calls)' should be renamed to something more specific and meaningful. Use a more meaningful and descriptive name for the step such as 'Step to audit oubound network calls'

testfiles/addworkflow/expected-scorecards.yml

  • [High]Do not use outdated dependencies
    The code is currently using an outdated version of ossf/scorecard-action. There may be critical security vulnerabilities present in the outdated dependencies. Update the version of ossf/scorecard-action used to the most recent release version.
  • [Medium]Pin dependencies to specific versions
    The code is not specifying exact versions of its dependencies. This can lead to unexpected behavior and security vulnerabilities if dependent packages change without warning. Specify the exact versions of all dependencies used in the codebase.
  • [Low]Use HTTPS instead of HTTP for downloading dependencies
    The code is currently using HTTP instead of HTTPS to download dependencies. This can potentially allow for MITM attacks on these downloads. Change the URLs of dependencies to use HTTPS where possible.

testfiles/secureworkflow/output/allscenarios.yml

  • [High]Audit all outbound network calls
    Audit all outbound network calls made by the runner to ensure that no suspicious traffic or data exfiltration is taking place. Replace the egress-policy parameter value with "audit-all"
  • [High]Use a trusted repository for the Harden Runner action
    Use a trusted repository and version for the Harden Runner action to avoid any security-related issues caused by using an untrusted or outdated version. Replace the uses parameter value with a trusted repository and version of the Harden Runner action.
  • [High]Remove hardcoded sensitive information
    Hardcoding sensitive information such as credentials in the code is a serious security risk as they could be exposed in case of a security breach. It should be avoided whenever possible. Use an encrypted secrets store or environment variable to store and retrieve sensitive information instead of hardcoding them in the code.
  • [Medium]Enable two-factor authentication for the GitHub account used by the runner
    Using two-factor authentication (2FA) for the GitHub account used by the runner adds an extra layer of security by requiring a security code in addition to the password. Enable two-factor authentication for the GitHub account used by the runner.
  • [Medium]Restrict network access for the runner
    Restricting network access for runners can limit the ability of attackers to exploit vulnerabilities or communicate with external systems if the runner is compromised. Restrict or filter network traffic for the runner, for example, by using a separate network segment or a VPN. Or, remove unnecessary network access if it is not needed for the runner to function.
  • [Low]Use HTTPS instead of HTTP for network requests
    Using HTTPS instead of HTTP to make network requests can prevent sensitive data from being intercepted or modified in transit. Change the URLs to use HTTPS instead of HTTP in the code.
  • [Low]Increase the verbosity of logging
    Increasing the verbosity of logging can help with troubleshooting and identifying potential security issues by providing more information about the runner's activity. Change the logging level to include more verbose messages in the code.

testfiles/secureworkflow/output/missingaction.yml

  • [High]Explicit Versioning of the External Dependency used for Hardening
    The External dependency used to harden the runner is specified using a non-explicit commit id. The remediation for this issue is that use a hard-coded version or tag for the external dependency which is used for hardening. This will ensure that the same version is always used to start the runner, ensuring the same hardening is always applied.
  • [Medium]Egress Policies with Exception Monitoring
    The Outbound calls from the runner is audited for compliance but there is no provision for monitoring of exception or failures. The remediation for this issue is to modify the egress policy to log exceptions and failures to a centralized system for monitoring

testfiles/secureworkflow/output/noperms.yml

  • [High]Avoid using wildcard in image or tag versions
    Using wildcards in image or tag versions leads to uncertainties and may cause uncontrolled deployment of code. The exact version should always be used to avoid any potential security vulnerabilities. Replace the wildcard symbol in the image or tag version with a specific version number or sha256 checksum of the image to ensure the exact version is always used.
  • [High]Log all outbound network calls
    Logging all outbound network calls from the runner can help in debugging and identifying any suspicious activity. Update the egress-policy input parameter to 'audit-and-log' from 'audit' in the step that hardens the runner.
  • [Medium]Avoid running the runner as root
    Running a runner as root increases the attack surface and vulnerabilities. Add a 'user: 1000' line to the workflow YAML file or the runner configuration file to change the user which runs the runner to a regular user instead of root.
  • [Medium]Use a private container registry instead of public ones
    Public container registries are not always secure and may expose secrets or other sensitive information. Configure a private container registry to store and deploy images instead of using a public one.
  • [Medium]Use environment variables to store secrets
    Hardcoding secrets in the pipeline YAML files or in the Docker images increases the risk of exposing these secrets. Use environment variables to store secrets, and pass these variables to the pipeline jobs using pipeline-specific secrets or other secure methods.
  • [Low]Include a License in the repository
    Including a license in the repository clarifies the legal terms under which the code is shared. Add a LICENSE file to the root of the repository containing the appropriate legal text.
  • [Low]Explicitly define job names
    Explicitly defining job names increases the readability and maintainability of the pipeline YAML files. Replace the name fields in the pipeline YAML files with descriptive job names that reflect the actual work being done.

Feedback

We appreciate your feedback in helping us improve the service! To provide feedback, please use emojis on this comment. If you find the comments helpful, give them a 👍. If they aren't useful, kindly express that with a 👎. If you have questions or detailed feedback, please create n GitHub issue in StepSecurity/AI-CodeWise.

Copy link

codecov bot commented Feb 1, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 66.00%. Comparing base (84135ad) to head (1f2d537).
Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2504   +/-   ##
=======================================
  Coverage   66.00%   66.00%           
=======================================
  Files          17       17           
  Lines        1812     1812           
=======================================
  Hits         1196     1196           
  Misses        525      525           
  Partials       91       91           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@varunsh-coder varunsh-coder merged commit d48f26d into main Feb 1, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants