| 1 | # Security Policy |
| 2 | |
| 3 | ## Supported Versions |
| 4 | Only the latest version of mimetype is supported. |
| 5 | |
| 6 | We will only release security updates for the latest version. |
| 7 | If you've discovered a security vulnerability in an older version of mimetype, |
| 8 | please report it and we will [retract](https://go.dev/ref/mod#go-mod-file-retract) |
| 9 | that version from module proxies. |
| 10 | |
| 11 | ## Reporting a Vulnerability |
| 12 | We want to keep our software safe for everyone. |
| 13 | |
| 14 | If you've discovered a security vulnerability in mimetype, |
| 15 | we appreciate your help in disclosing it to us in a responsible manner, |
| 16 | by creating a [security advisory](https://github.com/gabriel-vasile/mimetype/security/advisories). |
| 17 | |
| 18 | ## Threat model |
| 19 | These are the most common risk areas we think about when working on `mimetype`. |
| 20 | |
| 21 | ### Stealing maintainer's credentials |
| 22 | > The maintainers will have credentials stolen. |
| 23 | |
| 24 | Measures: |
| 25 | |
| 26 | 1. `2FA` authentication enabled for maintainers. |
| 27 | 2. `OIDC` auth for GitHub Actions instead of long lived access tokens. |
| 28 | |
| 29 | ### Malware in dependencies |
| 30 | > The library’s dependencies will be hijacked and malware will be installed to |
| 31 | importers of the library. |
| 32 | |
| 33 | Measures: |
| 34 | |
| 35 | 1. Eliminate dependencies: `mimetype` has no compile time dependencies, except for the Golang standard library. |
| 36 | 2. Keep a short list of Github Actions dependencies and pin them to a commit. |
| 37 | No workflows have write permission and a new release can only be done by a human maintainer. |
| 38 | |
| 39 | ### Logic errors in the library |
| 40 | > Logic errors in the library can lead to crashes or infinite loops. Specially |
| 41 | crafted inputs can exploit them and lead to denial-of-service attacks. |
| 42 | |
| 43 | Measures: |
| 44 | |
| 45 | 1. Fuzzing: complex code is fuzzed. |
| 46 | 2. Each release is tested against a [corpora of files](https://github.com/gabriel-vasile/mimetype_tests/) |
| 47 | that includes specially crafted, polyglot and edge-case files. |
| 48 | |
| 49 | ## Incident Response Plan |
| 50 | Next paragraphs outlines how we respond to security incidents, critical bugs, |
| 51 | or operational disruptions that could affect users or the trustworthiness of the project. |
| 52 | |
| 53 | ### Principles: |
| 54 | |
| 55 | - Transparency: All incidents and fixes are documented and publicly available. |
| 56 | - Stewardship: Take responsibility for protecting users and the project. |
| 57 | - Protection: Act to minimize harm and provide guidance. |
| 58 | |
| 59 | ### Identification |
| 60 | - Incidents may be identified through vulnerability reports, dependency alerts, or community reports. |
| 61 | - All reports received via GitHub Security Advisories are treated as potential incidents. |
| 62 | |
| 63 | ### Assessment |
| 64 | - The maintainer evaluates severity of the incident. |
| 65 | - Affected versions and attack surface are determined. |
| 66 | |
| 67 | ### Containment |
| 68 | - If a released version of the library is compromised, then it will be flagged in |
| 69 | the advisory and [retracted](https://go.dev/ref/mod#go-mod-file-retract). |
| 70 | - Users are directed to pin a known-safe version. |
| 71 | |
| 72 | ### Remediation |
| 73 | - A fix is developed and validated in a private branch. |
| 74 | - The fix is released as a new version of the library. |
| 75 | - The GitHub Security Advisory is updated with the fixed version and mitigation steps. |
| 76 | |
| 77 | ### Notification |
| 78 | - Users are notified through the GitHub Security Advisory. |
| 79 | - Critical issues may also be announced via release notes and the project README. |
| 80 | |
| 81 | ### Post-Incident Review |
| 82 | - The root cause and timeline are documented in the advisory. |
| 83 | - Process improvements are applied to prevent recurrence. |