Upload check: `isValidGlbMagic` skips the declared-length check the server enforces
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 88/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- javascript
- Área
- frontend
Línea de trabajo
Empieza en src/shared/glb-magic.js, donde isValidGlbMagic comprueba el magic y la versión, pero nunca lee la longitud declarada en el desplazamiento de bytes 8. Usa la comprobación del servidor en api/_lib/glb-inspect.js como referencia: rechaza cuando la longitud declarada es menor que 20 o mayor que file.size, leyendo aún solo file.slice(0, 12). Ejecuta primero la prueba del issue; una vez corregido, debe devolver false para ambas cabeceras. Está terminado cuando el nuevo tests/glb-magic.test.js pasa con npx vitest run y se cumplen los criterios de aceptación.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Context
Before a user's 3D model is uploaded, the browser checks its 12-byte GLB header so a misnamed JPEG is rejected instantly instead of after a full upload. That check is isValidGlbMagic in src/shared/glb-magic.js, used by src/create-agent.js and src/agent-edit.js.
Its header comment says it "mirrors the server-side isValidGlbHeader() in api/_lib/glb-inspect.js" and that it checks "that the declared file length field is at least the minimum GLB size". It does not check the length field at all. It checks the magic bytes and the version, then returns true.
The server version in api/_lib/glb-inspect.js does more:
const declaredLen = view.getUint32(8, true);
if (declaredLen > buf.length || declaredLen < 20) return false;
So a truncated or corrupted GLB (a valid 12-byte header whose declared length is larger than the file, or smaller than 20) passes the browser check and is only rejected after it has been uploaded. The two checks are supposed to agree, and today they do not. There is also no test for glb-magic.js.
Verified on main:
node --input-type=module -e "
import { isValidGlbMagic } from './src/shared/glb-magic.js';
const header = (declared) => { const b = new ArrayBuffer(12); const v = new DataView(b); v.setUint32(0, 0x46546c67, true); v.setUint32(4, 2, true); v.setUint32(8, declared, true); return b; };
console.log('declares 5000 bytes, file is 12:', await isValidGlbMagic(new File([header(5000)], 'a.glb')));
console.log('declares 8 bytes:', await isValidGlbMagic(new File([header(8)], 'a.glb')));
"
declares 5000 bytes, file is 12: true
declares 8 bytes: true
Both should be false, because the server rejects both.
What to change
In isValidGlbMagic, read the declared length (little-endian uint32 at byte offset 8) and return false when it is below 20 or larger than file.size, matching the server. Keep reading only the first 12 bytes; the point of the function is that it never buffers the whole file. Make the header comment match what the code does.
Add tests/glb-magic.test.js. Node 20 and later have a global File, so tests can build headers the way the probe above does.
Acceptance criteria
- A valid header whose declared length equals the file size returns
true. - Declared length larger than
file.sizereturnsfalse. - Declared length below 20 returns
false. - Wrong magic, version 1, a file under 12 bytes, and a missing file all return
false(these already do; lock them in). - The function still reads only
file.slice(0, 12). - The header comment describes exactly the checks the code performs.
How to test
npx vitest run tests/glb-magic.test.js
npm test
Good first issue: a small, well-bounded correctness fix with a clear reference implementation next door. Comment "taking this" before you start.
- Lenguaje dominante
- JavaScript
- Estrellas
- 230
- Forks
- 63
- Merge medio
- 15 h 43 min
- PR fusionados (30 d)
- 225
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de nirholas/three.ws
-
[Feature]: Add PayAPI MarketAbiertoenhancement triage
Dificultad 1/5 Menos de una hora Aptitud para principiantes 87/100
Los mantenedores suelen responder en 1 día
-
Money Pulse: compact numbers roll over into the wrong unit (`$1000`, `1000.0k`)Quizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abiertobug good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
nirholas/three.ws#344 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
bug triage
Dificultad 4/5 1-2 días Aptitud para principiantes 12/100
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 1-2 días Aptitud para principiantes 48/100
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 10/100
Los mantenedores suelen responder en 1 día
Todos los issues de nirholas/three.ws
Issues similares
-
Band: compact mode never draws on Claude Code 2.1.292 (level Button has a Text child)Posiblemente ocupada @Bunty9 la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
DietrichGebert/ponytail#1437 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
huggingface/transformers.js#1945 ·
Los mantenedores suelen responder en 1 día
-
Update: HTTP Headers Cheat SheetAbiertoACK_WAITING HELP_WANTED UPDATE_CS
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
OWASP/CheatSheetSeries#2977 ·
Los mantenedores suelen responder en 1 día
-
backend bug frontend
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
freshframework/fresh#3920 ·