-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
title: "EJS" | ||
description: "Cheatsheet on EJS" | ||
lead: "Cheatsheet on EJS" | ||
date: 2023-01-01T00:00:00+00:00 | ||
lastmod: 2023-01-01T00:00:00+00:00 | ||
draft: false | ||
images: [] | ||
menu: | ||
docs: | ||
parent: "ssti" | ||
weight: 620 | ||
toc: true | ||
--- | ||
|
||
## EJS - Embedded JavaScript templating | ||
|
||
[EJS](https://ejs.co/) is a simple templating language that lets you generate HTML markup with plain JavaScript. | ||
|
||
## XSS | ||
|
||
**Unsafe:** | ||
|
||
```html | ||
<h1><%- user.name %></h1> | ||
``` | ||
|
||
**Safe:** | ||
|
||
```html | ||
<h1><%= user.name %></h1> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
--- | ||
title: "Pug" | ||
description: "Cheatsheet on Pug" | ||
lead: "Cheatsheet on Pug" | ||
date: 2023-01-01T00:00:00+00:00 | ||
lastmod: 2023-01-01T00:00:00+00:00 | ||
draft: false | ||
images: [] | ||
menu: | ||
docs: | ||
parent: "ssti" | ||
weight: 620 | ||
toc: true | ||
--- | ||
|
||
## Pug | ||
|
||
[Pug](https://pugjs.org/) is a simple templating language that lets you generate HTML markup with plain JavaScript. | ||
|
||
## XSS | ||
|
||
### Unescaped Attributes | ||
|
||
- [Unescaped Attributes - pugjs.org](https://pugjs.org/language/attributes.html#unescaped-attributes) | ||
- [&attributes - pugjs.org](https://pugjs.org/language/attributes.html#attributes) | ||
|
||
By default, all attributes are escaped. If you need to use special characters, use `!=` instead of `=`. | ||
|
||
```html | ||
div(escaped="<code>") | ||
=> <div escaped="<code>"></div> | ||
div(unescaped!="<code>") | ||
=> <div unescaped="<code>"></div> | ||
|
||
p = 'This code <strong>is</strong> escaped!' | ||
=> <p>This code <strong>is</strong> !</p> | ||
p != 'This code is' + ' <strong>not</strong> escaped!' | ||
=> This code is <strong>not</strong> escaped! | ||
|
||
div#foo(data-bar="foo")&attributes({'data-foo': 'bar'}) | ||
=> <div id="foo" data-bar="foo" data-foo="bar"></div> | ||
``` | ||
|
||
> Attributes applied using `&attributes` are not automatically escaped. | ||
### Unescaped Strings | ||
|
||
- [String Interpolation, Unescaped - pugjs.org](https://pugjs.org/language/interpolation.html#string-interpolation-unescaped) | ||
|
||
**Safe:** | ||
|
||
```bash | ||
p You're logged in as #{user.name} | ||
``` | ||
**Unsafe:** | ||
```bash | ||
p You're logged in as !{user.name} | ||
``` | ||
|
||
### Unescaped Protocol | ||
|
||
```js | ||
a(href="javascript:alert(document.domain)") | ||
``` |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters