validateRideLength accepts any Object.prototype key as a ride length
Los mantenedores suelen responder en 7 días
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 78/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Tranquilo
- Stack tecnológico
- javascript
Línea de trabajo
Comienza en app/models/calEventValidator.js, en validateRideLength, y ejecuta en el directorio app la reproducción con node del issue. Comprueba la validación de propiedades propias y el comportamiento de las variables locales con los valores reales y los valores de Prototype-Key indicados. Se considera terminado cuando las longitudes de trayecto válidas siguen pasando, se rechazan las claves de Prototype y no se crea ningún valor global.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
validateRideLength uses the in operator to check a submitted ride length against the known values. in walks the prototype chain, so alongside the four real lengths it also accepts every property inherited from Object.prototype — toString, constructor, hasOwnProperty, valueOf, __proto__ — and returns them unchanged, with no validation error.
Those values reach the database and are rendered back on the event page.
Reproducing
From the app directory:
node -e "
const { makeValidator, ErrorCollector } = require('./models/calEventValidator');
for (const v of ['0-3', 'bogus', 'toString', 'constructor', '__proto__']) {
const errors = new ErrorCollector();
const got = makeValidator({ ridelength: v }, errors).validateRideLength('ridelength');
console.log(JSON.stringify(v).padEnd(15), '->', JSON.stringify(got));
}"
On main this prints:
"0-3" -> "0-3" (correct)
"bogus" -> null (correctly rejected)
"toString" -> "toString" (should be null)
"constructor" -> "constructor" (should be null)
"__proto__" -> "__proto__" (should be null)
hasOwnProperty and valueOf behave the same way. None of them record a validation error.
It reaches the database and the page
Posting an otherwise valid event to manage_event with ridelength: "constructor" (payload shape per CALENDAR_API.md) returns 200, and reading the event back through retrieve_event confirms it stored:
ridelength: "constructor"
EventDetails.vue renders the field directly:
rideLength() {
if (this.evt.ridelength) {
return `${this.evt.ridelength} miles`;
}
so the event details page then displays "constructor miles".
Cause
app/models/calEventValidator.js:
validateRideLength(rideLength) {
value = getString(rideLength);
return (value in RideLength) ? value : null;
}
RideLength is an ordinary frozen object, so it still inherits from Object.prototype, and in finds those inherited keys.
A second, smaller problem in the same function
value is assigned without const/let, so it becomes an implicit global on every call — confirmed with globalThis.value === "0-3" after one call. It is harmless today only because this file is non-strict CommonJS; it would throw a ReferenceError under ESM or "use strict", which is where the rest of the project is heading.
Suggested fix
Use an own-property check, and declare the local:
- validateRideLength(rideLength) {
- value = getString(rideLength);
- return (value in RideLength) ? value : null;
- },
+ validateRideLength(field) {
+ const value = getString(field);
+ return Object.hasOwn(RideLength, value) ? value : null;
+ },
Severity
Low. The column is a varchar, and Vue escapes its output, so this is bad data rather than injection — an organizer can write arbitrary prototype-key strings into a public field on their own ride. Worth fixing because it is small, and because the same in-instead-of-own-property pattern is easy to copy into somewhere it matters more.
Not changed
Unlike the other validators, this one silently returns null for an unrecognised value rather than recording an error via errors.addError(field). That may well be deliberate — rejecting a bad ride length outright would fail the whole save — so I have left the behaviour alone. Flagging it in case it should be revisited separately.
- Lenguaje dominante
- JavaScript
- Estrellas
- 30
- Forks
- 26
- Merge medio
- 6 d 24 min
- PR fusionados (30 d)
- 6
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Sin plantilla de pull request
- Sin 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 shift-org/shift-docs
-
Unknown --db values report a TypeError instead of the intended errorPosiblemente ocupada @gangster la tomó hace 72 días. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
shift-org/shift-docs#1091 ·
Los mantenedores suelen responder en 7 días
-
Favorites page fetches every favorite because getDaily's guard is invertedPosiblemente ocupada @gangster la tomó hace 72 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
shift-org/shift-docs#1087 ·
Los mantenedores suelen responder en 7 días
-
Address npm audit vulnerabilities (nodemailer, multer, express deps)Posiblemente ocupada @gangster la tomó hace 1 día. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
shift-org/shift-docs#1118 · 1 comentario ·
Los mantenedores suelen responder en 7 días
-
Add an endpoint for Biiikes to check whether an email address organizes an eventQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 25/100
shift-org/shift-docs#1106 · 1 comentario ·
Los mantenedores suelen responder en 7 días
-
sitemap.xml emits relative <loc> values, so search engines reject itPosiblemente ocupada @dduugg la tomó hace 98 días. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 68/100
shift-org/shift-docs#1082 ·
Los mantenedores suelen responder en 7 días
Todos los issues de shift-org/shift-docs
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Los mantenedores suelen responder en 1 día
-
Github token for private repoAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
tshemsedinov/reslop#158 ·
Los mantenedores suelen responder en 1 día
-
level/task type/bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
wazuh/wazuh-documentation#10398 ·
Los mantenedores suelen responder en 1 día
-
app_installations reports an error on every repo or suborg change when the plugin is not configuredAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 64/100
github-community-projects/safe-settings#1111 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día