diff --git a/sig-security/sig-security-tooling/vulnerability-mgmt/README.md b/sig-security/sig-security-tooling/vulnerability-mgmt/README.md new file mode 100644 index 00000000000..77cee3496d0 --- /dev/null +++ b/sig-security/sig-security-tooling/vulnerability-mgmt/README.md @@ -0,0 +1,59 @@ +# Vulnerability Management + +Covers Kubernetes wide vulnerability management process, policies and workflows +that tackle *known* vulnerabilities in Kubernetes artifacts that can be found +via automation + +## Goals + +1. Identify known vulnerabilities in Kubernetes artifacts by scanning them + periodically +2. Leverage the existing triage and resolution process (i.e. Github issues, PRs) + to document and resolve any vulnerabilities that impact Kubernetes +3. Create community driven awareness and documentation around known CVEs in + Kubernetes related artifacts + +### Vulnerability Triage and Resolution Process + +Leverage community driven triage and impact assessment to resolve known +vulnerabilities in Kubernetes artifacts. More details can be +found [here](process-for-vulnerability-triage-and-resolution.md) + +### Build Time Dependencies + +A tool agnostic periodic scanning of build time dependencies +(typically dependencies found in `go.mod` file) of Kubernetes. More details can +be found [here](build-time-dependencies.md) + +This track is a partnership between SIG +Architecture's [Code Organization](https://github.com/kubernetes/community/tree/master/sig-architecture#code-organization) +sub-project and SIG Security's Tooling sub-project + +### Container Images + +Automating triage and resolution of vulnerabilities as it relates to container +images in Kubernetes Github Org. This effort is beginning to take form and is being tracked in +[Issue #5920](https://github.com/kubernetes/community/issues/5920) + +This track is a partnership +between [SIG Release](https://github.com/kubernetes/sig-release) +and SIG Security's Tooling sub-project + +**Note**: Artifacts here refer to code, images and binaries + +## Non-Goals + +1. **Responsible disclosure of vulnerabilities**: This will continue to be the + responsibility + of [Security Response Committee](https://github.com/kubernetes/community/tree/master/committee-product-security/README.md) +2. **Runtime dependencies**: Triaging of vulnerabilities found in components + that are runtime dependencies for an on-premises or *-as-a-service* + Kubernetes deployment. Examples include but are not limited to container + runtimes, container registries, Node OS +3. **Resolving license violations**: Allowed third party license policy can be + found [here](https://github.com/cncf/foundation/blob/master/allowed-third-party-license-policy.md#approved-licenses-for-allowlist) + +**Note**: If you have a topic that you think is missing, please hop on over to +our +[slack channel](https://kubernetes.slack.com/messages/sig-security-tooling) +to discuss more :-) \ No newline at end of file diff --git a/sig-security/sig-security-tooling/vulnerability-mgmt/build-time-dependencies.md b/sig-security/sig-security-tooling/vulnerability-mgmt/build-time-dependencies.md new file mode 100644 index 00000000000..9d4ec3d0539 --- /dev/null +++ b/sig-security/sig-security-tooling/vulnerability-mgmt/build-time-dependencies.md @@ -0,0 +1,319 @@ +# Periodic scanning for vulnerabilities in build time dependencies + +Report vulnerabilities in build time dependencies +of [Kubernetes](https://github.com/kubernetes/kubernetes) repository + +Tracker: [Issue #101528](https://github.com/kubernetes/kubernetes/issues/101528) + +## Background and Prior work + +The process described here is tooling agnostic i.e. the process can be +implemented using any scanner with minimal or no changes. This is also _not_ an +endorsement of any specific tool or scanner. In order to get a working solution +in place, [snyk](https://snyk.io/) was chosen for following reasons: + +1. Existing partnership between CNCF and Snyk helped procure an account that + allowed us to scan `kubernetes/kubernetes` + repo: https://github.com/kubernetes/steering/issues/206 +2. Snyk has detected vulnerabilities in transient dependencies of + `kubernetes/kubernetes`: https://kubernetes.slack.com/archives/CHGFYJVAN/p1595258034095300 +3. Snyk has a programmable interface which made it easier to filter out + licensing issues and known false positive vulnerabilities + +## Implementation with Snyk + +There are two ways to scan the Kubernetes repo for vulnerabilities in +dependencies at build time + +### Running the scan locally + +#### Step 0: Install Snyk CLI + +Follow these instructions to snyk cli installed on your +machine: https://support.snyk.io/hc/en-us/articles/360003812538-Install-the-Snyk-CL + +#### Step 1: Authenticate + +##### Option A : + +Running command `snyk auth` takes you to snyk.io website, do signup/login/auth + +``` +snyk auth +``` + +##### Option B: + +Get the API token from https://app.snyk.io/account and use it + +``` +snyk auth XXX-XXX-XXX-XXX-XXX +Your account has been authenticated. Snyk is now ready to be used. +``` + +#### Step 2: Run test + +``` +# in k/k repo +snyk test +``` + +### Running the scan as part of k/k testgrid + +Prow job that runs every 6 hours is located +here: https://testgrid.k8s.io/sig-security-snyk-scan#ci-kubernetes-snyk-master + +#### Improvements to the raw scan results + +Raw scan results were useful, but needed some Kubernetes specific work + +##### JSON output + +To store the json output in a file and let stdout use command line friendly +output: + +``` +snyk test --json-file-output=licenses-cves.json +``` + +##### Licenses + +Since detecting licensing violations is a non-goal, licenses related results, +can be removed from the output using this query: + +``` +cat licenses-cves.json | jq '.vulnerabilities | .[] | select (.type=="license" | not)' > only_cves.json +``` + +##### Removing False Positive CVEs identified with v0.0.0 + +Since these are really pointing to the code at HEAD in git tracking, we can +ignore the vulnerabilities that are generated when snyk detects v0.0.0 as +Kubernetes version because of the way +[replace](https://github.com/golang/go/wiki/Modules#when-should-i-use-the-replace-directive) +directives are used. + +Easy way to remove licensing *and* CVEs like this: + +``` +cat licenses-cves.json | jq '.vulnerabilities | .[] | select ((.type=="license") or (.version=="0.0.0") | not)' > only_cves_wo000.json +``` + +### Example of filtered JSON scan result + +__Note__: Results of the filtered scan are not printed as part of the CI job. +However, the following historical scan result is mentioned here for +reference purposes only: + + +
Click to view result + + +``` +{ + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H", + "alternativeIds": [], + "creationTime": "2021-02-08T10:27:10.200417Z", + "credit": [ + "Unknown" + ], + "cvssScore": 7.2, + "description": "## Overview\n\nAffected versions of this package are vulnerable to Directory Traversal. When specifying the plugin to load in the `type` field in the network configuration, it is possible to use special elements such as \"../\" separators to reference binaries elsewhere on the system. An attacker can use this to execute other existing binaries other than the cni plugins/types such as `reboot`.\n\n## Details\n\nA Directory Traversal attack (also known as path traversal) aims to access files and directories that are stored outside the intended folder. By manipulating files with \"dot-dot-slash (../)\" sequences and its variations, or by using absolute file paths, it may be possible to access arbitrary files and directories stored on file system, including application source code, configuration, and other critical system files.\n\nDirectory Traversal vulnerabilities can be generally divided into two types:\n\n- **Information Disclosure**: Allows the attacker to gain information about the folder structure or read the contents of sensitive files on the system.\n\n`st` is a module for serving static files on web pages, and contains a [vulnerability of this type](https://snyk.io/vuln/npm:st:20140206). In our example, we will serve files from the `public` route.\n\nIf an attacker requests the following URL from our server, it will in turn leak the sensitive private key of the root user.\n\n```\ncurl http://localhost:8080/public/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/root/.ssh/id_rsa\n```\n**Note** `%2e` is the URL encoded version of `.` (dot).\n\n- **Writing arbitrary files**: Allows the attacker to create or replace existing files. This type of vulnerability is also known as `Zip-Slip`. \n\nOne way to achieve this is by using a malicious `zip` archive that holds path traversal filenames. When each filename in the zip archive gets concatenated to the target extraction folder, without validation, the final path ends up outside of the target folder. If an executable or a configuration file is overwritten with a file containing malicious code, the problem can turn into an arbitrary code execution issue quite easily.\n\nThe following is an example of a `zip` archive with one benign file and one malicious file. Extracting the malicious file will result in traversing out of the target folder, ending up in `/root/.ssh/` overwriting the `authorized_keys` file:\n\n```\n2018-04-15 22:04:29 ..... 19 19 good.txt\n2018-04-15 22:04:42 ..... 20 20 ../../../../../../root/.ssh/authorized_keys\n```\n\n## Remediation\nUpgrade `github.com/containernetworking/cni/pkg/invoke` to version 0.8.1 or higher.\n## References\n- [GitHub PR](https://github.com/containernetworking/cni/pull/808)\n- [RedHat Bugzilla Bug](https://bugzilla.redhat.com/show_bug.cgi?id=1919391)\n", + "disclosureTime": "2021-02-05T00:00:00Z", + "exploit": "Not Defined", + "fixedIn": [ + "0.8.1" + ], + "functions": [], + "functions_new": [], + "id": "SNYK-GOLANG-GITHUBCOMCONTAINERNETWORKINGCNIPKGINVOKE-1070549", + "identifiers": { + "CVE": [ + "CVE-2021-20206" + ], + "CWE": [ + "CWE-22" + ] + }, + "language": "golang", + "modificationTime": "2021-02-08T14:14:51.744734Z", + "moduleName": "github.com/containernetworking/cni/pkg/invoke", + "packageManager": "golang", + "packageName": "github.com/containernetworking/cni/pkg/invoke", + "patches": [], + "proprietary": false, + "publicationTime": "2021-02-08T14:14:51.968123Z", + "references": [ + { + "title": "GitHub PR", + "url": "https://github.com/containernetworking/cni/pull/808" + }, + { + "title": "RedHat Bugzilla Bug", + "url": "https://bugzilla.redhat.com/show_bug.cgi?id=1919391" + } + ], + "semver": { + "hashesRange": [ + " + ] + }, + "severity": "high", + "severityWithCritical": "high", + "title": "Directory Traversal", + "from": [ + "k8s.io/kubernetes@0.0.0", + "github.com/containernetworking/cni/libcni@0.8.0", + "github.com/containernetworking/cni/pkg/invoke@0.8.0" + ], + "upgradePath": [], + "isUpgradable": false, + "isPatchable": false, + "name": "github.com/containernetworking/cni/pkg/invoke", + "version": "0.8.0" +} +{ + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N", + "alternativeIds": [], + "creationTime": "2020-07-30T13:33:31.283115Z", + "credit": [ + "christopher-wong" + ], + "cvssScore": 7.5, + "description": "## Overview\n[github.com/dgrijalva/jwt-go](https://github.com/dgrijalva/jwt-go) is a go implementation of JSON Web Tokens.\n\nAffected versions of this package are vulnerable to Access Restriction Bypass if `m[\"aud\"]` happens to be `[]string{}`, as allowed by the spec, the type assertion fails and the value of `aud` is `\"\"`. This can cause audience verification to succeed even if the audiences being passed are incorrect if `required` is set to `false`.\n## Remediation\nUpgrade `github.com/dgrijalva/jwt-go` to version 4.0.0-preview1 or higher.\n## References\n- [GitHub Issue](https://github.com/dgrijalva/jwt-go/issues/422)\n- [GitHub PR](https://github.com/dgrijalva/jwt-go/pull/426)\n", + "disclosureTime": "2020-07-30T13:22:28Z", + "exploit": "Not Defined", + "fixedIn": [ + "4.0.0-preview1" + ], + "functions": [], + "functions_new": [], + "id": "SNYK-GOLANG-GITHUBCOMDGRIJALVAJWTGO-596515", + "identifiers": { + "CVE": [ + "CVE-2020-26160" + ], + "CWE": [ + "CWE-287" + ] + }, + "language": "golang", + "modificationTime": "2020-11-30T11:23:07.967004Z", + "moduleName": "github.com/dgrijalva/jwt-go", + "packageManager": "golang", + "packageName": "github.com/dgrijalva/jwt-go", + "patches": [], + "proprietary": false, + "publicationTime": "2020-09-13T15:53:35Z", + "references": [ + { + "title": "GitHub Issue", + "url": "https://github.com/dgrijalva/jwt-go/issues/422" + }, + { + "title": "GitHub PR", + "url": "https://github.com/dgrijalva/jwt-go/pull/426" + } + ], + "semver": { + "hashesRange": [ + "v4.0.0-preview1" + ], + "vulnerable": [ + "<4.0.0-preview1" + ], + "vulnerableHashes": null + }, + "severity": "high", + "severityWithCritical": "high", + "title": "Access Restriction Bypass", + "from": [ + "k8s.io/kubernetes@0.0.0", + "github.com/heketi/heketi/client/api/go-client@10.2.0", + "github.com/dgrijalva/jwt-go@3.2.0" + ], + "upgradePath": [], + "isUpgradable": false, + "isPatchable": false, + "name": "github.com/dgrijalva/jwt-go", + "version": "3.2.0" +} +{ + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N", + "alternativeIds": [], + "creationTime": "2020-07-30T13:33:31.283115Z", + "credit": [ + "christopher-wong" + ], + "cvssScore": 7.5, + "description": "## Overview\n[github.com/dgrijalva/jwt-go](https://github.com/dgrijalva/jwt-go) is a go implementation of JSON Web Tokens.\n\nAffected versions of this package are vulnerable to Access Restriction Bypass if `m[\"aud\"]` happens to be `[]string{}`, as allowed by the spec, the type assertion fails and the value of `aud` is `\"\"`. This can cause audience verification to succeed even if the audiences being passed are incorrect if `required` is set to `false`.\n## Remediation\nUpgrade `github.com/dgrijalva/jwt-go` to version 4.0.0-preview1 or higher.\n## References\n- [GitHub Issue](https://github.com/dgrijalva/jwt-go/issues/422)\n- [GitHub PR](https://github.com/dgrijalva/jwt-go/pull/426)\n", + "disclosureTime": "2020-07-30T13:22:28Z", + "exploit": "Not Defined", + "fixedIn": [ + "4.0.0-preview1" + ], + "functions": [], + "functions_new": [], + "id": "SNYK-GOLANG-GITHUBCOMDGRIJALVAJWTGO-596515", + "identifiers": { + "CVE": [ + "CVE-2020-26160" + ], + "CWE": [ + "CWE-287" + ] + }, + "language": "golang", + "modificationTime": "2020-11-30T11:23:07.967004Z", + "moduleName": "github.com/dgrijalva/jwt-go", + "packageManager": "golang", + "packageName": "github.com/dgrijalva/jwt-go", + "patches": [], + "proprietary": false, + "publicationTime": "2020-09-13T15:53:35Z", + "references": [ + { + "title": "GitHub Issue", + "url": "https://github.com/dgrijalva/jwt-go/issues/422" + }, + { + "title": "GitHub PR", + "url": "https://github.com/dgrijalva/jwt-go/pull/426" + } + ], + "semver": { + "hashesRange": [ + "v4.0.0-preview1" + ], + "vulnerable": [ + "<4.0.0-preview1" + ], + "vulnerableHashes": null + }, + "severity": "high", + "severityWithCritical": "high", + "title": "Access Restriction Bypass", + "from": [ + "k8s.io/kubernetes@0.0.0", + "k8s.io/apiserver/pkg/storage/etcd3/testing@0.0.0", + "go.etcd.io/etcd/integration@#dd1b699fc489", + "go.etcd.io/etcd/etcdserver/api/v3rpc@#dd1b699fc489", + "go.etcd.io/etcd/mvcc@#dd1b699fc489", + "go.etcd.io/etcd/auth@#dd1b699fc489", + "github.com/dgrijalva/jwt-go@3.2.0" + ], + "upgradePath": [], + "isUpgradable": false, + "isPatchable": false, + "name": "github.com/dgrijalva/jwt-go", + "version": "3.2.0" +} + +``` + +
diff --git a/sig-security/sig-security-tooling/vulnerability-mgmt/process-for-vulnerability-triage-and-resolution.md b/sig-security/sig-security-tooling/vulnerability-mgmt/process-for-vulnerability-triage-and-resolution.md new file mode 100644 index 00000000000..dc395213336 --- /dev/null +++ b/sig-security/sig-security-tooling/vulnerability-mgmt/process-for-vulnerability-triage-and-resolution.md @@ -0,0 +1,48 @@ +# Process for Vulnerability Triage and Resolution + +Depending on the assessed impact of the vulnerability, appropriate resolution +is triggered to apply the fix to Kubernetes or document the reason for not fixing + +## Assumptions + +- For undisclosed or non-public vulnerabilities, the +[responsible disclosure process](https://kubernetes.io/docs/reference/issues-security/security/) + is followed +- Reduce the window of opportunity for an attacker for exploiting known + vulnerabilities by shortening the gap between *mean time to detect* and *mean + time to fix* + +## Triage process + +- The vulnerabilities are triaged in private, by members of + `security-tooling-private@kubernetes.io` +- Membership to this group is restricted due to the confidential nature of the + responsibilities +- Once a vulnerability is found through automation, the group members get + notified via an email about it +- One of the SIG Security Tooling member on rotation triggers assessment of the + reported vulnerability as follows: + + |No. | Category | Definition | Teams | Assessment | Resolution | + |---|---|---|---|---|---| + | 1 | False positive | Kubernetes and vulnerable artifact is not impacted by this CVE | SIG Security Tooling | Open a Github issue and log the resolution as *False Positive* in issue description. Appropriate labels will be added to get attention from code owners when required | Not Applicable + | 2 | True positive: No impact | Artifact version used in Kubernetes is vulnerable, but Kubernetes is not using the vulnerable code | **Lead**: SIG Security Tooling, **Partners**: Release Engineering, K8s Code Organization | Open a Github issue and log the resolution as *True Positive: No Impact* in the issue description with reasoning behind assessed impact | Existing Issue assignment, PR creation, review and approval process is followed to ensure relevant code owners are involved in some capacity.
The fix is applied to subsequent release of Kubernetes + | 3 | True positive: Negligible impact | Artifact version used in Kubernetes is vulnerable, and Kubernetes is using the vulnerable code, but the vulnerability does not apply to Kubernetes | **Lead**: SIG Security Tooling, **Partners**: Release Engineering, K8s Code Organization, Security Response Committee | SIG Security Tooling and Security Response Committee discuss the security implications of the vulnerability privately. If needed, the vulnerability is reclassified to Category 4.

If the category is unchanged, open a Github issue classifying the vulnerability into category *True Positive: Negligible Impact*. It should also include reasoning behind assessed impact including but not limited to existence of a compensatory control* | Same as category 2 + | 4 | True positive: With impact | Artifact version used in Kubernetes is vulnerable, and Kubernetes is using the vulnerable code | **Lead**: SIG Security Tooling, **Partners**: Release Engineering, K8s Code Organization, Security Response Committee | SIG Security Tooling and Security Response Committee discuss the security implications of the vulnerability privately. If needed, the vulnerability is reclassified to Category 3.

If category is unchanged, open a Github issue classifying the vulnerability into category *True Positive: With Impact*. It should also include the reasoning behind assessed impact, modified CVSS rating for Kubernetes if applicable and any workarounds that completely or partially mitigate the vulnerability | Issue is followed soon with PRs that cherry pick the fixes to master/main and all the supported [versions](https://kubernetes.io/releases/version-skew-policy/#supported-versions). Code Owners if not creating the PR should review, approve and merge the PR within a reasonable time duration depending on severity of impact.
The Release managers ensure that the vulnerability fix is then, shipped with the next patch release of Kubernetes. + | 5 | Embargoed vulnerability | No CVE ID is assigned so scanners do not detect it | Security Response Committee, Release Engineering | This category is only mentioned here for completeness | [Security Release Process](https://github.com/kubernetes/security/blob/master/security-release-process.md#disclosures) + +*Example of a compensating control: The vulnerability can be exploited only when unsafe user input can be injected but Kubernetes is doing input verification prior to accepting user input + +## Examples + +- [CVE-2020-26160](https://github.com/kubernetes/kubernetes/issues/100401) +- [CVE-2021-20206](https://github.com/kubernetes/kubernetes/issues/101758) + +## Next Steps + +1. Create ignore lists for category 1, 2 and 3. Build a process to evaluate + ignore lists for category 2 and 3 periodically. +2. Formalize or + modify [this](https://github.com/kubernetes/security/blob/master/security-release-process.md#severity-thresholds---how-we-do-vulnerability-scoring) + process from Product Security Committee / Security Response Committee, when + the modifying original CVSS score makes sense \ No newline at end of file