Files
ALPHA-TRAIN2/services/tiktak/video/probe.go
T
bobiqqandClaude Opus 5 753d21c3e8
build-and-push / detect (push) Successful in 12s
build-and-push / build (${{ fromJSON(needs.detect.outputs.services) }}) (push) Successful in 33s
tiktak: принимать legacy-токены для старых видео + fail-open в probe
MUMBLE "failed to get access using private key": чекер держит share-токен,
выданный ещё старым keygen, а после перехода на HMAC ValidateKey его
отвергал.

- keygen/legacy.go: восстановленный из keygen.a алгоритм
  seed=(seed*17+42)%62 принимается ТОЛЬКО для video.id <= cutoff, то есть
  для видео, существовавших на момент перехода. Выше cutoff -- лишь HMAC.
- cutoff берётся из max(video.id) при первом старте и пишется в
  public/.legacy_cutoff на volume: рестарт не должен расширять окно.
  Не смогли прочитать -- fail closed, legacy выключен.
- Когда старые флаги протухнут: echo 0 > public/.legacy_cutoff + рестарт,
  и legacy отключается полностью.

Ещё MUMBLE "cannot create video" -- он же DoS, у NOP-команды то же самое:
- checkGeometry сделан FAIL-OPEN. Неразобранный ffprobe больше не отклоняет
  загрузку, режем только успешно прочитанную и абсурдную геометрию.
- ffmpeg -max_alloc 128M: 1080p кадру нужно ~8 МБ, бомбе ~1 ГБ. Работает
  даже когда probe промолчал.

check_tiktak.sh: smoke-тест для vulnbox, гоняет сценарий чекера целиком
и отдельно проверяет, что патчи реально в задеплоенном билде.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-26 12:25:45 +03:00

45 lines
1.4 KiB
Go

package video
import (
"context"
"fmt"
"os/exec"
"strings"
)
// Decompression-bomb guard. A 100 KB webm can carry a 16383x16383 VP8 frame
// (the format's maximum): tiny on disk, ~1 GB once ffmpeg expands it to raw
// pixels. Probing the container header is cheap -- ffprobe reads metadata and
// never decodes a frame -- so we reject absurd geometry before any decoding.
const (
MaxDimension = 4096
MaxPixels = 8 << 20 // 8 Mpx, ~4x a 1080p frame
)
func checkGeometry(ctx context.Context, inp string) error {
args := []string{"-v", "error", "-select_streams", "v:0",
"-show_entries", "stream=width,height", "-of", "csv=s=x:p=0", inp}
// FAIL-OPEN on purpose. A probe that errors out or prints something we do
// not understand must NOT reject the upload: the checker's video would
// start failing with "cannot create video" and that costs more than the
// bomb does. Only a geometry we successfully read and that is absurd is
// rejected. Bombs need a real, huge, parseable resolution to be bombs.
out, err := exec.CommandContext(ctx, "ffprobe", args...).Output()
if err != nil {
return nil
}
var w, h int
if _, err := fmt.Sscanf(strings.TrimSpace(string(out)), "%dx%d", &w, &h); err != nil {
return nil
}
if w <= 0 || h <= 0 {
return nil
}
if w > MaxDimension || h > MaxDimension || w*h > MaxPixels {
return fmt.Errorf("video resolution %dx%d is not supported", w, h)
}
return nil
}