You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refactor filesystem operations to validate repository paths and references
This commit introduces robust validation for repository paths and references within the filesystem operations.
In internal/storage/filesystem.go, the sanitizeReference function is updated to return an error for invalid reference strings, including checks for empty strings, path separators, and invalid characters. This change is mirrored in the PutManifest function to ensure that references are sanitized before being used to construct paths.
The Filesystem struct methods, specifically ManifestPath, PutManifest, and linkManifestTag, now explicitly check for errors returned by sanitizeReference, ensuring that only valid references are processed.
Tests are updated to validate this new behavior. internal/storage/filesystem_test.go now includes a new test, TestFilesystemRejectsUnsafeTagReferences, which attempts to use various unsafe tag references to confirm that PutManifest, LinkManifestTag, and GetManifest reject them, enforcing the new validation logic.
Additionally, internal/auth/password.go is updated to enforce a check against parallelism values in argon2 parameters, preventing overflows when setting secret hash parallelism.
Configuration changes in internal/config/config.go update the structure of HTTPConfig and Default() to explicitly set SecureCookies to true, aligning with potential security requirements. Tests in
Copy file name to clipboardExpand all lines: README.md
+10Lines changed: 10 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -52,6 +52,7 @@ The published Docker image starts SCR with `-config /etc/scr/config.yaml`. The i
52
52
http:
53
53
address: "0.0.0.0"
54
54
port: 5000
55
+
secureCookies: true
55
56
56
57
storage:
57
58
rootDirectory: "/var/lib/scr/registry"
@@ -84,6 +85,7 @@ docker run --rm --name scr \
84
85
Configuration supports these sections:
85
86
86
87
- `http.address`and `http.port`
88
+
- `http.secureCookies`; defaults to `true`. Leave enabled when SCR is accessed over HTTPS, including behind an HTTPS-terminating reverse proxy. Set to `false` only when serving the admin UI directly over plain HTTP.
87
89
- `storage.rootDirectory`
88
90
- `storage.gc`
89
91
- `storage.gcDelay`
@@ -111,6 +113,14 @@ Bootstrap admin username and password are normally provided with environment var
111
113
112
114
If bootstrap admin values are omitted from the config file, SCR fills them from those environment variables. Provide both values together.
113
115
116
+
### Admin UI cookies and reverse proxies
117
+
118
+
SCR stores admin UI sessions in an `HttpOnly`, `SameSite=Lax` cookie. By default, `http.secureCookies` is `true`, which also marks that cookie `Secure` so browsers only send it over HTTPS.
119
+
120
+
Keep `http.secureCookies: true` for production deployments, including the common setup where a reverse proxy terminates HTTPS and forwards plain HTTP to SCR. The browser only sees the public HTTPS URL, so the `Secure` cookie works normally even if the proxy-to-SCR hop is HTTP.
121
+
122
+
Set `http.secureCookies: false` only when users access SCR directly over plain HTTP, such as a local development instance or a trusted internal HTTP-only deployment. Do not disable it for an HTTPS reverse-proxy deployment.
123
+
114
124
## Authentication and access
115
125
116
126
Registry clients use Docker-compatible bearer-token authentication:
ifadminValidityResponse.Code!=http.StatusOK||!strings.Contains(adminValidityResponse.Body.String(), "Admin users are managed outside this user list") {
0 commit comments