Skip to content

Server-Side Template Injection in webhooks, export templates and custom links. #6921

@kkthxbye-code

Description

@kkthxbye-code

NetBox version

v.2.11.10

Python version

3.8

Steps to Reproduce

  1. Create a site
  2. Create export template for sites
  3. Fill out required fields
  4. Enter {{ ''.__class__.__mro__[1].__subclasses__()[199]('id', shell=True,stdout=-1).communicate()}} in template code. Indexes for mro and subclasses will probably differ per instance.
  5. Go to sites and execute the export template
  6. Open generated csv file

Expected Behavior

Error or default csv file generated

Observed Behavior

.csv file contains (b'uid=101 gid=0(root)\n', None)

Suggestions

I see two immediate options.

  1. Make it clear in the documentation that having rights to create webhooks, export templates or custom links is dangerous and allows RCE on the host.
  2. Use the jinja2 sandbox: https://jinja.palletsprojects.com/en/3.0.x/sandbox/

With option 2 there should probably still be a note in the documentation, as sandboxes are rarely known to be perfect.

Metadata

Metadata

Assignees

Labels

status: acceptedThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the application

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions