Media files are reachable unauthenticated #10461

Closed
opened 2025-12-29 21:31:46 +01:00 by adam · 4 comments
Owner

Originally created by @Andres1357 on GitHub (Nov 8, 2024).

Originally assigned to: @jeremystretch on GitHub.

Deployment Type

Self-hosted

Triage priority

N/A

NetBox Version

v4.1.6

Python Version

3.12

Steps to Reproduce

  1. Install NetBox v4.1.0 - 4.1.6 and ensure configuration variable LOGIN_REQUIRED = True.
  2. Add an image attachment to any object and get the URL to the image
    (https://yournetbox.com/media/image-attachments/yourimage.png)
  3. Attempt to access that URL while logged out of NetBox.

I've reproduced this in various NetBox versions (4.1.0, 4.1.1, 4.1.5, 4.1.6) both as standalone and in Docker.

It is reproducible using the Documents plugin as well as it also stores files in the media directory (https://yournetbox.com/media/netbox-documents/doc.pdf)

I've also reproduced it on https://netbox-demo.netboxlabs.com, though I can't confirm if that instance has LOGIN_REQUIRED = True.

Expected Behavior

It is my understanding that NetBox should not display the file and instead redirect to the login page if the variable LOGIN_REQUIRED = True. This was the behavior seen on NetBox v4.0.3.

Observed Behavior

NetBox displays the file just as if you were logged in.
image

Originally created by @Andres1357 on GitHub (Nov 8, 2024). Originally assigned to: @jeremystretch on GitHub. ### Deployment Type Self-hosted ### Triage priority N/A ### NetBox Version v4.1.6 ### Python Version 3.12 ### Steps to Reproduce 1. Install NetBox v4.1.0 - 4.1.6 and ensure configuration variable LOGIN_REQUIRED = True. 2. Add an image attachment to any object and get the URL to the image (https://yournetbox.com/media/image-attachments/yourimage.png) 3. Attempt to access that URL while logged out of NetBox. I've reproduced this in various NetBox versions (4.1.0, 4.1.1, 4.1.5, 4.1.6) both as standalone and in Docker. It is reproducible using the Documents plugin as well as it also stores files in the media directory (https://yournetbox.com/media/netbox-documents/doc.pdf) I've also reproduced it on https://netbox-demo.netboxlabs.com, though I can't confirm if that instance has LOGIN_REQUIRED = True. ### Expected Behavior It is my understanding that NetBox should not display the file and instead redirect to the login page if the variable LOGIN_REQUIRED = True. This was the behavior seen on NetBox v4.0.3. ### Observed Behavior NetBox displays the file just as if you were logged in. ![image](https://github.com/user-attachments/assets/4c4633bf-b37d-474e-a49c-19b62da79ad8)
adam added the type: bugstatus: acceptedseverity: high labels 2025-12-29 21:31:46 +01:00
adam closed this issue 2025-12-29 21:31:46 +01:00
Author
Owner

@Andres1357 commented on GitHub (Nov 8, 2024):

I believe change #16580 may be the cause.

@Andres1357 commented on GitHub (Nov 8, 2024): I believe change #16580 may be the cause.
Author
Owner

@Azmodeszer commented on GitHub (Nov 11, 2024):

Can confirm this.

@Azmodeszer commented on GitHub (Nov 11, 2024): Can confirm this.
Author
Owner

@jeremystretch commented on GitHub (Nov 12, 2024):

We'll need to implement a custom wrapper view to inherit from ConditionalLoginRequiredMixin and ensure LOGIN_REQUIRED is enforced consistently for static media.

@jeremystretch commented on GitHub (Nov 12, 2024): We'll need to implement a custom wrapper view to inherit from ConditionalLoginRequiredMixin and ensure `LOGIN_REQUIRED` is enforced consistently for static media.
Author
Owner

@Andres1357 commented on GitHub (Nov 12, 2024):

Thanks Jeremy!

@Andres1357 commented on GitHub (Nov 12, 2024): Thanks Jeremy!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10461