A caller-supplied ASIN reaches log lines unsanitized
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
- 77/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- csharp
- Área
- backend, observability, security
Línea de trabajo
Empieza con listenarr.application/Metadata/Core/AudiobookMetadataService.cs y MetadataConverters.cs; luego usa como lista de verificación la lista del diff de la rama con 106 argumentos de registro de ASIN sin procesar en 26 archivos. Ejecuta primero tests/Features/Application/Security/Redaction/AsinLogForgingTests.cs; sanea cada ASIN registrado con LogRedaction.SanitizeText y confirma que las pruebas y la suite de backend se ejecuten correctamente.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Raised by the batch-B review of PR 768.
What happens
An ASIN is a route parameter on GET /metadata/{asin} and GET /metadata/audible/{asin}, a request
field on advanced search, and a body field on the add call. It is caller-supplied text, and nothing
constrains it to the shape of an ASIN before it is logged.
LogRedaction.SanitizeText exists for this and is used in 380 places. It is not used consistently
for ASINs. The clearest example is inside one method:
// listenarr.application/Metadata/Core/AudiobookMetadataService.cs:58-64, at a630572e
_logger.LogInformation("Found {Count} enabled metadata sources for ASIN {Asin}: {Sources}",
metadataSources?.Count ?? 0, LogRedaction.SanitizeText(asin), ...);
if (metadataSources == null || !metadataSources.Any())
{
_logger.LogWarning("No enabled metadata sources found for ASIN {Asin}", asin);
Line 59 sanitizes the value and line 64 does not, with nothing between them to explain the
difference. MetadataConverters.cs logs an ASIN raw in 22 places.
I counted the whole set rather than guessing at it: 106 log arguments across 26 files pass an
ASIN-shaped value straight to the logger. The list is in the branch diff.
Why it matters
A value carrying a newline forges an extra line in any plain-text sink:
B01E633FQM
2026-01-01 00:00:00 INFO Authentication disabled by administrator
A reader of that log, or anything parsing it, cannot tell the forged line from a real one. The
advanced-search request body is the straightforward way in, since a JSON string field takes an
escaped newline without argument. A percent-encoded newline in the {asin} path segment would do
it too, if the host does not reject the request first; I have not tested which way that goes and
the body path does not depend on it. The length bound matters separately: an unbounded request
field is an unbounded log line.
This is not a data-sensitivity question. An ASIN is a public catalogue identifier and the repository
logs it freely elsewhere, which is fine. The problem is that user-controlled text reaches a log
without being flattened first.
Suggested fix
Pass every logged ASIN through LogRedaction.SanitizeText, the same function the neighbouring lines
already use. It replaces newlines, carriage returns and tabs with spaces, trims, and truncates at
200 characters.
One transform, repeated: 106 arguments, 26 files, no logic change. The only visible difference is
that a null or blank ASIN now prints as [empty] rather than as nothing, which is what every other
SanitizeText call site in the repository already does.
I am happy to split this by area if one change across 26 files is harder to review than several.
Tests
tests/Features/Application/Security/Redaction/AsinLogForgingTests.cs, four cases against a
capturing logger:
SanitizeTextflattens a forged log line and keeps the ASIN that preceded it- the metadata converter emits no log message containing a newline or carriage return when handed a
forged ASIN - the converter still reports a well-formed ASIN, which is the control: without it, a version that
simply stopped logging the value would pass the case above - the metadata lookup emits no forged line either, exercising the route-parameter path end to end
With the sweep reverted and the tests kept, two of the four fail on the newline assertion. Full
backend suite on the branch: 3122 passing, 0 failing, 130 skipped.dotnet format --verify-no-changesclean.
Relationship to #768
#768 edits AudiobookMetadataService.cs and MetadataConverters.cs, which is where this first
became visible, but the two are unrelated and this is deliberately not folded into it. #768 is a
series-identifier fix and grew once already.
Disclosure: drafted with Claude Code at my direction; I read the cited code at the stated commit and reviewed this before posting.
- Lenguaje dominante
- C#
- Estrellas
- 901
- Forks
- 70
- Merge medio
- 16 h 27 min
- PR fusionados (30 d)
- 60
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 Listenarrs/Listenarr
-
Search button on a book does not retry without the author when the full query finds nothingPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Listenarrs/Listenarr#1173 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Listenarrs/Listenarr#1133 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Listenarrs/Listenarr#1128 ·
Los mantenedores suelen responder en 1 día
-
Add New's search splits a title that contains "Series:", "Author:"… as if they were search keywordsAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
Listenarrs/Listenarr#1127 ·
Los mantenedores suelen responder en 1 día
-
p2
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Listenarrs/Listenarr#959 ·
Los mantenedores suelen responder en 1 día
Todos los issues de Listenarrs/Listenarr
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
conductor-oss/csharp-sdk#183 ·
-
CreateNewLangProj throws when the default analysis writing system's ICU locale differs from its tagAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
-
kind/bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
unoplatform/uno#26555 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
CactuseSecurity/firewall-orchestrator#5739 ·
Los mantenedores suelen responder en 1 día
-
Bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
Los mantenedores suelen responder en 1 día