fix(loader-server): a broken or looping symlink in the build folder crashes startup

Ouverte
#146 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
68/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
bun, typescript
Domaine
backend, security

Piste de recherche

Read apps/server/src/files.ts and apps/client/src/files.ts, starting with the getFiles and addPath functions cited in the report. Check how each handles symlinks, filesystem errors, and paths that resolve outside the build folder. Done means broken or cyclic links no longer crash startup or recurse indefinitely, and files outside the build folder are not listed or served.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

app:client app:server bug
Which app is this bug report for?

server

Issue description

Also affects client.

getFiles uses statSync, which follows symlinks, and catches nothing:

  • a dangling link throws ENOENT and the server loader dies at startup;
  • a link to a parent folder recurses until the stack overflows.

The client's addPath catches errors per entry but loops the same way on cyclic links. A symlink inside the build folder that points outside it is also served, because resolveInside only checks the path as a string.

Found by reading the code path (not reproduced).

Expected: symlinks don't crash the loader, and only files inside the build folder are listed and served.

Suggested fix: use lstat and skip symlinks (or resolve them with realpath and keep only targets inside the root), and catch errors per entry.

Found during a read-only audit of main @ 044c766 (2026-11-11).

Code sample
const addPath = (path: string, exportedPath: string) => {
  if (fs.statSync(path).isDirectory()) { // follows symlinks, throws on dangling ones
    for (const file of fs.readdirSync(path)) addPath(join(path, file), join(exportedPath, file));
    return;
  }
  paths.push([`/${exportedPath}`, path]);
};
Versions
  • @nanoforge-dev/loader-client / @nanoforge-dev/loader-server / @nanoforge-dev/loader-website 1.7.0 (main @ 044c766)
  • Bun 1.3.14
  • Linux x86_64
Issue priority

Low (slightly annoying)

I have tested this issue on a development release

044c766

Langage dominant
TypeScript
Étoiles
1
Forks
0
Merge moyen
17 h 25 min
PR mergées (30 j)
11

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de NanoForge-dev/Loader

Toutes les issues de NanoForge-dev/Loader

Issues similaires

Plus d'issues TypeScript

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.