From d8d4a77ba74cdc6217da0b557405a82e56795698 Mon Sep 17 00:00:00 2001 From: Andy Dixon Date: Sat, 7 Feb 2026 12:18:26 +0000 Subject: [PATCH] Use random job and snapshot IDs Timestamp-derived IDs were guessable, and the ID is what grants access to indexed source. crypto/rand.Text gives 26 base32 characters. --- main.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 5bf53a6..046faf2 100644 --- a/main.go +++ b/main.go @@ -3,6 +3,7 @@ package main import ( "bufio" "bytes" + "crypto/rand" "embed" "encoding/json" "errors" @@ -19,7 +20,6 @@ import ( "strconv" "strings" "sync" - "sync/atomic" "time" "unicode/utf8" ) @@ -620,10 +620,9 @@ func safeRelativePath(value string) (string, bool) { return filepath.Join(clean...), true } -var idCounter atomic.Uint64 - +// uniqueID is unguessable: IDs are the capability that grants access to a job or snapshot. func uniqueID(prefix string) string { - return fmt.Sprintf("%s-%x%x", prefix, time.Now().UnixNano(), idCounter.Add(1)) + return prefix + "-" + rand.Text() } func writeError(w http.ResponseWriter, status int, message string) {