Fixes #20442: Mark template-accessible methods with alters_data=True #355

Closed
opened 2026-04-05 16:27:05 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @jnovinger on 2/13/2026

Fixes: #20442

Add alters_data=True to methods that modify database or filesystem state and are accessible from Jinja2 sandbox template contexts (config templates, export templates, webhooks, custom links).

Methods protected:

  • UserConfig.set(), clear() - Persist preference changes when commit=True
  • ManagedFile.sync_data() - Writes files to scripts/reports storage
  • ScriptModule.sync_classes(), sync_data() - Creates/deletes Script objects
  • Job.start(), terminate() - Updates job status, creates notifications

Methods intentionally not protected:

  • DataFile.refresh_from_disk() - Only modifies instance attributes in memory, doesn't persist
  • Overridden save()/delete() - Django's AltersData mixin auto-propagates from parent
  • Properties like Script.python_class - Not callable in template context

Ref: #20356 for exploit details

*Originally created by @jnovinger on 2/13/2026* Fixes: #20442 Add `alters_data=True` to methods that modify database or filesystem state and are accessible from Jinja2 sandbox template contexts (config templates, export templates, webhooks, custom links). ### Methods protected: - `UserConfig.set()`, `clear()` - Persist preference changes when `commit=True` - `ManagedFile.sync_data()` - Writes files to scripts/reports storage - `ScriptModule.sync_classes()`, `sync_data()` - Creates/deletes Script objects - `Job.start()`, `terminate()` - Updates job status, creates notifications ### Methods intentionally not protected: - `DataFile.refresh_from_disk()` - Only modifies instance attributes in memory, doesn't persist - Overridden `save()`/`delete()` - Django's `AltersData` mixin auto-propagates from parent - Properties like `Script.python_class` - Not callable in template context Ref: #20356 for exploit details
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/netbox#355