Repository navigation
Security
Anchor LFS includes several security features to protect your data and infrastructure.
All transfer URLs (download, upload, verify) are signed with HMAC-SHA256 to prevent unauthorised access and URL tampering.
- During batch negotiation, the server generates action URLs with two query parameters:
-
exp: Expiration timestamp (Unix epoch) -
sig: Base64-encoded HMAC-SHA256 signature computed over the operation (download, upload or verify), the full URL and the expiration
-
- When a client uses the URL, the server recomputes the signature for the operation of the route and the URL the request arrived at, and checks expiration
- Expired or tampered URLs are rejected with a
403 Forbiddenresponse, as are URLs used for another operation (such as a download URL used to upload), at another scheme or host, or with any other query parameter
The URL a request arrived at starts with base_url when it is set. Without base_url, it is built from the Host header, or from X-Forwarded-Proto and X-Forwarded-Host sent by a peer in trusted_proxies, so transfer requests must reach the server with the same values as the batch request that issued them.
A signed URL needs no other credentials: whoever holds it can use it until it expires. It works only for its operation, its object and the server address it was issued for, but it is not tied to a user or a client IP address, the same as the transfer URLs GitHub issues for its own LFS storage. The signature is checked when a transfer starts, so an upload or download that starts before the expiry finishes even if it runs past it.
Signed URLs can show up in:
-
Reverse proxy access logs, which usually record the full request line,
sigincluded. Anchor LFS's own access log records only the path -
Git LFS debug output:
GIT_TRACE=1andGIT_CURL_VERBOSE=1print them, so treat a shared trace as sensitive untilurl_expiryhas passed
To limit the exposure:
- Lower
url_expiry(default 10 minutes). Git LFS asks for a new URL when one has expired before its transfer starts, so a shorter expiry mostly costs extra batch requests - Restrict who can read proxy logs, or log without the query string (with Nginx, use
$uriinstead of$requestin thelog_format) - Rotate the signing key to revoke every outstanding URL at once
Batch, lock and download responses send Cache-Control: no-store, so a caching proxy does not keep signed URLs or objects. Presigned S3 URLs follow the same rules: they expire after url_expiry, and rotating the S3 credentials revokes them.
[options]
# HMAC signing key (hex-encoded, minimum 32 bytes / 64 hex characters)
# If omitted, auto-generated and saved to <data_directory>/signing.key
#signing_key = ""
# How long signed URLs remain valid (default: 10m)
#url_expiry = "10m"-
Auto-generated: If no
signing_keyis configured, a random 32-byte key is generated at startup and saved to<data_directory>/signing.keyso it persists across restarts -
Manual: Generate a key with
openssl rand -hex 32and set it in the config, viaANCHOR_LFS_SIGNING_KEY, or in a file named byANCHOR_LFS_SIGNING_KEY_FILE - Minimum size: 32 bytes (64 hex characters)
- Memory safety: Signing key material is zeroed in memory during graceful shutdown
- Rotation: See Rotating the Signing Key
Anchor LFS supports one running instance per data_directory (see Storage Backends). If two instances overlap, for example while a server is being replaced, they must use the same signing_key; otherwise a URL signed by one instance is rejected by the other. An auto-generated key lives in the data_directory, so set the key explicitly in the configuration whenever the instances do not share that directory.
Per-IP rate limiting protects the batch and lock API against abuse using a fixed window counter.
[options]
rate_limit_tokens = 600
rate_limit_window = "1m"- Per-IP: Each client IP gets its own budget
-
Real IP detection: The client IP is taken from
X-Forwarded-Foronly when the request comes from a peer intrusted_proxies(loopback and private ranges by default), using the rightmost address that is not itself a trusted proxy, or the leftmost when every address is one. Otherwise it is the connecting address, so a directly connected client cannot pick its own IP. See Reverse Proxy. -
Fixed window: Each IP may make
rate_limit_tokensrate-limited requests perrate_limit_window. The budget is restored in full when the window ends, not gradually, so keep the window short: with a24hwindow, a client that runs out waits up to a day. - Rate-limited endpoints: Batch and all lock operations
- Not rate-limited: Object download, upload and verify. These need a signed, time-limited URL that only a rate-limited batch request can issue, and one batch request covers up to 1,000 objects (Git LFS sends 100 at a time).
- Fail-open: If the rate limiter encounters an internal error, requests pass through rather than being rejected (prevents limiter failures from causing outages)
-
429 response: Rate-limited requests receive HTTP
429 Too Many Requestswith aRetry-Afterheader giving the seconds until the window ends. Git LFS clients wait that long and retry.
Object IDs (OIDs) must be exactly 64 hexadecimal characters (representing a SHA-256 hash). Invalid OIDs are rejected by the HTTP layer (422 in a batch or verify request, 404 in a download or upload URL), and the storage adapters independently validate every OID before building a filesystem path or S3 key, so a malformed OID can never reach the disk or the bucket.
-
Content-Lengthheader is required for all uploads - Uploads exceeding
max_upload_sizeare rejected during batch negotiation - Local storage and proxied S3 uploads compute the SHA-256 while receiving the data and store the object only if it matches the declared OID
- Presigned S3 uploads sign the expected SHA-256 and size into the URL, so the storage provider rejects any other bytes (see Storage Backends)
- An object whose hash does not match is never written
Lock paths are the repository-relative paths Git LFS sends, and are stored only as text in locks.json. The server answers 422 to a lock request whose path breaks these rules:
- Must be a relative path in valid UTF-8, with
/between directories - Rejects empty,
.and..elements, so a leading or trailing/,//,./and traversal are all refused - Rejects null bytes
- Allows backslashes, colons and Windows reserved names such as
CON, which Git allows in file names on Linux and macOS
The rules are the same whichever operating system the server runs on.
Endpoint paths become storage directory names by dropping the leading slash and replacing / with _ (/org/repo becomes org_repo). Paths containing unsafe characters, dot segments or empty segments, and paths whose directory names would collide, are rejected when the configuration is loaded.
- JSON request bodies are capped at 1 MB
- Batch requests accept a maximum of 1000 objects
LFS endpoints strictly validate Content-Type and Accept headers, rejecting requests that don't use application/vnd.git-lfs+json.
ReadHeaderTimeout: 10 seconds
IdleTimeout: 120 seconds
Upload idle: 60 seconds without data (upload_idle_timeout)
ReadTimeout: (none; supports large transfers)
WriteTimeout: (none; supports large transfers)
- ReadHeaderTimeout protects against slowloris attacks during the header phase
- IdleTimeout closes idle keep-alive connections after 2 minutes
-
upload_idle_timeout abandons an upload with
408 Request Timeoutwhen its client sends no data for 60 seconds (configurable), so a client trickling bytes cannot hold a connection and a temporary file open indefinitely - Total read and write timeouts are intentionally omitted to support large file transfers without killing legitimate connections
Uploads are streamed directly to storage without in-memory buffering, preventing memory exhaustion from large files.
The optional metrics endpoint has no authentication, and it shows endpoint paths, request rates and free disk space. It is served only on metrics_address, never on listen_address, so bind that to loopback or a private network and keep it out of the reverse proxy.
When running behind a reverse proxy:
Warning
Always set base_url in production. Without it, the server relies on X-Forwarded-* headers to construct transfer URLs. If a reverse proxy is misconfigured or absent, clients could manipulate these headers to redirect LFS transfers to a malicious server. Setting base_url eliminates this attack surface entirely.
-
Use
base_url: Settingbase_urlin the configuration eliminates reliance onX-Forwarded-*headers, removing header-based attack surface -
Header validation: The
X-Forwarded-Hostheader is validated as a URL authority to prevent header injection -
Restrict direct access: Bind the server to
127.0.0.1or use Docker networking so it's only accessible through the proxy
See Reverse Proxy for detailed proxy configuration.
- GitHub Personal Access Tokens are never logged or stored
- Auth cache entries are keyed by a hash of the token (not the token itself)
- Each token is checked for its own contents permission, not only its owner's role, so a read-only or narrowly scoped token cannot upload, take locks or read a private repository it was not granted
- Transient authentication failures (network errors) are not cached, preventing permanent lockouts from temporary issues
- The shared HTTP client for GitHub API calls uses a 10-second timeout
See Authentication for details.
- Configuration: Security-related configuration options
- Reverse Proxy: Secure proxy setup
- Troubleshooting: Security-related issues