Custom fields description allows arbitrary HTML tags #5550

Closed
opened 2025-12-29 19:29:19 +01:00 by adam · 2 comments
Owner

Originally created by @tombe75 on GitHub (Oct 22, 2021).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v3.0.8

Python version

3.8

Steps to Reproduce

  1. Add new Custom Field
  2. Set description with a HTML tag, e.g. A<h1>B</h1>C
  3. Assign to arbitrary model, e.g. circuit.
  4. Create a new object of selected model, circuit in this case.
  5. Check Custom Fields section when editing new object.

Expected Behavior

Since custom field creation is moved from admin page and could be available to normal users, I expect it to be sanitized from pure HTML.
(If some customization is needed this could be replaced with Markdown)

Observed Behavior

HTML tags gets evaluated.
bild

Originally created by @tombe75 on GitHub (Oct 22, 2021). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v3.0.8 ### Python version 3.8 ### Steps to Reproduce 1. Add new Custom Field 2. Set description with a HTML tag, e.g. `A<h1>B</h1>C` 3. Assign to arbitrary model, e.g. circuit. 4. Create a new object of selected model, circuit in this case. 5. Check Custom Fields section when editing new object. ### Expected Behavior Since custom field creation is moved from admin page and could be available to normal users, I expect it to be sanitized from pure HTML. (If some customization is needed this could be replaced with Markdown) ### Observed Behavior HTML tags gets evaluated. <img width="912" alt="bild" src="https://user-images.githubusercontent.com/50360366/138403696-c6a0137b-f2e1-4235-b28d-a7b7de13b01b.png">
adam added the type: bugstatus: accepted labels 2025-12-29 19:29:19 +01:00
adam closed this issue 2025-12-29 19:29:19 +01:00
Author
Owner

@kkthxbye-code commented on GitHub (Oct 27, 2021):

@jeremystretch - I think this solution is incomplete. Instead of strip_tags you should use the escape function from django.utils.html

Otherwise you can still mess up the HTML on the page with something like this:

"><iframe src=httpbin.org

As a sidenote, in cases like these where the fix is not part of a release yet, do you want a new issue, or a comment in the existing issue like this?

@kkthxbye-code commented on GitHub (Oct 27, 2021): @jeremystretch - I think this solution is incomplete. Instead of strip_tags you should use the escape function from django.utils.html Otherwise you can still mess up the HTML on the page with something like this: "><iframe src=httpbin.org As a sidenote, in cases like these where the fix is not part of a release yet, do you want a new issue, or a comment in the existing issue like this?
Author
Owner

@jeremystretch commented on GitHub (Nov 3, 2021):

As a sidenote, in cases like these where the fix is not part of a release yet, do you want a new issue, or a comment in the existing issue like this?

A follow-up comment is usually fine provided it's a minor adjustment and the change hasn't made it into a release yet. Thanks!

@jeremystretch commented on GitHub (Nov 3, 2021): > As a sidenote, in cases like these where the fix is not part of a release yet, do you want a new issue, or a comment in the existing issue like this? A follow-up comment is usually fine provided it's a minor adjustment and the change hasn't made it into a release yet. Thanks!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#5550