Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

High severity - Improper Control of Generation of Code ('Code Injection') vulnerability in pug-code-gen (package.json) #212

Open
github-actions bot opened this issue Aug 15, 2024 · 0 comments

Comments

@github-actions
Copy link

  • Package Manager: npm
  • Vulnerable module: pug-code-gen
  • Introduced through: juice-shop@12.3.0, pug@3.0.2 and others

Detailed paths

  • Introduced through: juice-shop@12.3.0 › pug@3.0.2 › pug-code-gen@3.0.2

Overview

pug-code-gen is a Default code-generator for pug. It generates HTML via a JavaScript template function.

Affected versions of this package are vulnerable to Improper Control of Generation of Code ('Code Injection') via the name option of the compileClient, compileFileClient, or compileClientWithDependenciesTracked functions. An attacker can execute arbitrary JavaScript code by providing untrusted input.

Note:

These functions are for compiling Pug templates into JavaScript, and there would typically be no reason to allow untrusted callers.

PoC

const express = require("express")
const pug = require("pug")
const runtimeWrap = require('pug-runtime/wrap');

const PORT = 3000

const app = express()

app.get("/", (req, res) => {
  const out = runtimeWrap(pug.compileClient('string of pug', req.query))
  res.send(out())
})

app.listen(PORT, () => {
  console.log(`Server is running on port ${PORT}`)
})

Remediation

Upgrade pug-code-gen to version 3.0.3 or higher.

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants