From 392253c5636c8e9a1d4d0d46c94c70b8134187c6 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Sat, 25 Jul 2026 08:42:52 +0200 Subject: [PATCH] docs: update SECURITY.md and add CLAUDE.md --- .claude/CLAUDE.md | 127 ++++++++++++++++++++++++++++++++++++++++++++++ SECURITY.md | 37 ++++++++------ 2 files changed, 149 insertions(+), 15 deletions(-) create mode 100644 .claude/CLAUDE.md diff --git a/.claude/CLAUDE.md b/.claude/CLAUDE.md new file mode 100644 index 00000000..cbe70fdc --- /dev/null +++ b/.claude/CLAUDE.md @@ -0,0 +1,127 @@ +# CLAUDE.md + +Guidance for Claude when working in this repository (File Browser, `filebrowser/filebrowser`). + +## Repo orientation + +- Go backend (`github.com/filebrowser/filebrowser/v2`, ecosystem `go`) + Vue frontend under `frontend/`. +- The project is in **maintenance-only mode** (see `SECURITY.md`). Prefer small, surgical, well-tested changes. +- Version scheme: `v2.63.x`. Conventional-commit messages (`fix(scope): …`, `feat: …`, `chore: …`). +- Verify with `go build ./...`, `go vet ./...`, `go test ./...`. Reuse existing test harnesses (e.g. `signToken`, `scopedUserStorage`, `handle`, `customFSUser`, `mockUserStore`). + +--- + +# Handling security advisories + +Use this playbook when asked to triage, verify, fix, or manage GitHub security advisories. +All advisory state lives on GitHub and is driven with the `gh` CLI. States are +`triage → draft → published`, plus `closed`. + +## 1. Fetch + +```bash +# List by state (also: published, draft, closed) +gh api '/repos/filebrowser/filebrowser/security-advisories?state=triage&per_page=100' \ + --jq '.[] | {ghsa_id, severity, summary, state}' + +# Full report for one advisory (read .summary and .description) +gh api /repos/filebrowser/filebrowser/security-advisories/GHSA-xxxx-xxxx-xxxx \ + --jq '.summary, "---", .description' +``` + +Always pull the **published** set too — you need it to dedup against. + +## 2. Verify each report — do NOT trust the report text + +Read the actual source **at HEAD** and reach one verdict per advisory: + +- **CONFIRMED** — defect exists at HEAD. Quote the exact `file:line`. +- **FIXED** — already patched (find the fix commit). +- **FALSE / NOT APPLICABLE** — claim is wrong, or targets a different project. +- **NOT EXPLOITABLE** — pattern exists but no code path can reach the precondition. +- **DUPLICATE** — of a published advisory, or of another triage advisory. + +Common traps — check each before accepting a report: + +- **"Incomplete fix of a prior advisory."** Read the original fix commit and confirm the *specific* + sibling code path is actually still unguarded — a prior fix may already cover a related path. +- **Wrong project.** Confirm the referenced files, symbols, and endpoints exist in this repo; reports + sometimes describe a fork. If the cited code isn't here, close as not applicable. +- **"Legacy / upgraded / imported records are affected."** Trace the field's git history and confirm that + some released version could actually produce such a record before believing it + (`git log -S'Field' -- path`, `git show `, `git tag --contains `). +- **Overlapping reports.** Two triage advisories may share one root cause — consolidate and fix once. +- **Known, intentionally-unaddressed classes.** Some areas are known and tracked but not fixed (see + `SECURITY.md`'s Known Issues); matching reports are duplicates. + +Record, per advisory: verdict, the `file:line` evidence, exploitability preconditions +(default config? platform-specific? auth required?), and the disposition. + +## 3. Fix (one commit per advisory) + +- Branch off `master` first; never commit fixes directly to `master`. +- **One commit per fix**, each referencing the GHSA in the body (`Refs GHSA-xxxx-xxxx-xxxx`). +- When several advisories share a root cause because parallel code paths diverged, **centralize** the logic + (e.g. `settings.CreateUserHome` used by signup, proxy, and hook provisioning) so they cannot drift again. +- Keep it surgical; match surrounding style. + +## 4. Add a regression test per fix + +- Reuse the existing harnesses; add a focused test asserting the fixed behavior (and that the legitimate + path still works). Commit tests alongside or right after the fixes (`test(scope): …`, `Refs GHSA-…`). +- Run `go test ./... && go vet ./...` before finishing. + +## 5. Severity — set a CVSS vector, don't hand-assert + +Set a CVSS v3.1 vector; GitHub derives the score **and** severity from it (overriding the plain `severity` +field). Encode the real preconditions in the vector so the band is defensible: + +- Requires a specific target configuration/platform (e.g. case-insensitive FS) → **AC:H**. +- Unauthenticated vs needs an account → **PR:N / PR:L**. +- Keep it consistent with the **predecessor CVE's** rating (an incomplete-fix follow-up should not outrank + its parent). Bands: `0.1–3.9` low, `4.0–6.9` medium, `7.0–8.9` high, `9.0–10.0` critical. + +```bash +gh api -X PATCH /repos/filebrowser/filebrowser/security-advisories/GHSA-xxxx-xxxx-xxxx \ + -f cvss_vector_string='CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H' \ + --jq '{ghsa_id, severity, score: .cvss.score, vector: .cvss.vector_string}' +``` + +## 6. Clean up the title + +Rewrite reporter titles to the concise, sentence-case, backtick-free style of the published advisories +(state the vuln; drop "Incomplete fix of…" prefixes and jargon). The title is the `summary` field: + +```bash +gh api -X PATCH .../security-advisories/GHSA-xxxx-xxxx-xxxx \ + -f summary='Proxy-auth auto-provisioning ignores createUserDir and grants the server root scope' +``` + +## 7. Set affected & patched versions + +The package is always `{ecosystem: "go", name: "github.com/filebrowser/filebrowser/v2"}`. +`patched_versions` must be the release that will actually ship the fix (cut it — it does not exist just +because the branch does). + +```bash +printf '%s' '{"vulnerabilities":[{"package":{"ecosystem":"go","name":"github.com/filebrowser/filebrowser/v2"},"vulnerable_version_range":"<= 2.63.18","patched_versions":"2.63.19","vulnerable_functions":[]}]}' \ + | gh api -X PATCH .../security-advisories/GHSA-xxxx-xxxx-xxxx --input - +``` + +## 8. Move state / close, by disposition + +```bash +gh api -X PATCH .../security-advisories/GHSA-xxxx-xxxx-xxxx -f state=draft # fixed, awaiting release +gh api -X PATCH .../security-advisories/GHSA-xxxx-xxxx-xxxx -f state=closed # duplicate / N-A / not-exploitable +``` + +- **CONFIRMED & fixed** → metadata done → **draft**. Publish after the patched release ships. +- **DUPLICATE / NOT APPLICABLE / NOT EXPLOITABLE** → **closed**. +- **DEFERRED** (confirmed but not yet fixed) → leave in **triage** with a note. +- The REST API **cannot post advisory comments** — replies to reporters (dup notice, evidence, links to + the relevant tracking issue) must be posted manually in the advisory UI. Draft the text for the maintainer. + +## 9. Release & publish + +Push the branch, open a PR, merge, tag/release the `patched_versions` you set, then publish the drafts. +Confirm outward-facing/irreversible advisory actions (close, publish) with the maintainer before doing them. diff --git a/SECURITY.md b/SECURITY.md index 490a9bea..4d8bb2a8 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -2,25 +2,32 @@ ## Supported Versions -Use this section to tell people about which versions of your project are -currently being supported with security updates. +| Version | Supported | +| ------- | --------- | +| 2.x | ✅ | +| < 2.0 | ❌ | -| Version | Supported | -| ------- | ------------------ | -| 2.x | :white_check_mark: | -| < 2.0 | :x: | +## Before Reporting + +This project is in maintenance-only mode. To avoid duplicates, first check the [existing advisories](https://github.com/filebrowser/filebrowser/security/advisories) and open issues, and confirm: + +- **It concerns this project, not a fork.** Reports about code, features, or endpoints that don't exist here belong to the relevant fork. +- **It isn't an already-known class** that remains unaddressed: + - Command execution, runner, and hooks (opt-in, disabled by default) — [#5199](https://github.com/filebrowser/filebrowser/issues/5199) + - Session and JWT handling — [#5216](https://github.com/filebrowser/filebrowser/issues/5216) + +Reports covering these are likely to be closed as duplicates. ## Reporting a Vulnerability -Vulnerabilities with critical impact should be reported on the [Security](https://github.com/filebrowser/filebrowser/security) page of this repository, which is a private way of communicating vulnerabilities to maintainers. This project is in maintenance-only mode and it can take a while until someone gets back to you. +- **Critical:** report privately via the [Security](https://github.com/filebrowser/filebrowser/security) page. +- **Non-critical:** open a public issue so the community can help; we'll label it as a security issue. -If it is not a critical vulnerability, please open an issue and we will categorize it as a security issue. By giving visibility, we can get more help from the community at fixing such issues. +Please include, where possible: -When reporting an issue, where possible, please provide at least: +- The commit the issue was found at +- A plaintext proof of concept (no binaries) +- Steps to reproduce +- Recommended remediation, if any -* The commit version the issue was identified at -* A proof of concept (plaintext; no binaries) -* Steps to reproduce -* Your recommended remediation(s), if any. - -The File Browser team is a volunteer-only effort, and may reach back out for clarification. +We're a volunteer effort, so responses can take a while, and we may reach out for clarification.