Skip to content

fix(security): register extension.manager.supports_csrf_post feature flag (4.2.1)#2820

Closed
ltdrdata wants to merge 1 commit intomanager-v4from
fix/csrf-post-feature-flag
Closed

fix(security): register extension.manager.supports_csrf_post feature flag (4.2.1)#2820
ltdrdata wants to merge 1 commit intomanager-v4from
fix/csrf-post-feature-flag

Conversation

@ltdrdata
Copy link
Copy Markdown
Member

Summary

  • Register extension.manager.supports_csrf_post = True on ComfyUI core's SERVER_FEATURE_FLAGS at Manager startup, so frontends (ComfyUI_frontend, 3rd-party extensions) can detect CSRF-POST backend capability as a semantic contract via the existing api.getServerFeature(...) mechanism.
  • Version bump: 4.24.2.1.
  • CHANGELOG entry for [4.2.1].
  • No endpoint or security behavior change — purely a capability-signal patch following up fix(security): harden CSRF with Content-Type gate and expand E2E coverage #2818.

Why a new flag (not version parsing)

Version-string parsing (V4.2 vs V4.1) is an implementation-detail check, not a semantic capability contract. Clients that parse the version string couple themselves to Manager's version-format convention (pre-release tags, future version-string format changes, etc.). A server-pushed feature flag is the right abstraction: it declares intent (“this backend supports POST-only state mutation”) independently of the version string.

Coordinated with the ComfyUI_frontend team (cmfront) so they can adopt this flag as the probe for their "NEW_UI vs INCOMPATIBLE" decision. Pre-4.2.1 Manager does not set the flag → frontends treat its absence as incompatible and surface an "upgrade Manager" action to the user.

Mechanism

# comfyui_manager/__init__.py — module load
try:
    from comfy_api import feature_flags as _core_feature_flags
    _mgr_flags = (
        _core_feature_flags.SERVER_FEATURE_FLAGS
        .setdefault("extension", {})
        .setdefault("manager", {})
    )
    _mgr_flags["supports_csrf_post"] = True
except ImportError:
    pass  # older ComfyUI core without comfy_api.feature_flags

.setdefault chain coexists with the pre-existing extension.manager.supports_v4 (hardcoded in core).

Delivery: ComfyUI core pushes SERVER_FEATURE_FLAGS via the WebSocket handshake (see server.py:296) and via GET /api/feature_flags (see server.py:689). Clients use their existing feature-flag infrastructure; no new endpoint on the Manager side.

Test plan

  • python -m py_compile comfyui_manager/__init__.py → OK
  • Smoke test (mocked comfy_api.feature_flags with a pre-seeded supports_v4=True): setdefault chain preserves supports_v4 and writes supports_csrf_post=True → final dict exactly {'extension': {'manager': {'supports_v4': True, 'supports_csrf_post': True}}}
  • ruff check comfyui_manager/ --config ruff.toml → All checks passed
  • pytest tests/ --ignore=tests/e2e --ignore=tests/playwright --ignore=tests/common/test_git_helper.py -q → 206 passed, 12 skipped (no regression)
  • grep ^version pyproject.tomlversion = "4.2.1"
  • CI: Code Quality / Ruff / OpenAPI spec / E2E (ubuntu/macOS/Windows)

Related

References

  • Reported-by: XlabAI Team of Tencent Xuanwu Lab
  • CVSS: 8.1 (AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:H)

…flag (4.2.1)

Expose CSRF-POST backend capability as a semantic contract via ComfyUI core's
feature_flags mechanism, so frontends (ComfyUI_frontend, extensions) can detect
it without parsing version strings. Pre-4.2.1 Manager does not set the flag —
clients observe its absence and should treat the backend as "incompatible with
POST-only state-mutation endpoints" and prompt the user to upgrade.

Follow-up patch to 4.2 (PR #2818); no endpoint or security behavior change.

Reported-by: XlabAI Team of Tencent Xuanwu Lab
CVSS: 8.1 (AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:H)
ltdrdata added a commit to Comfy-Org/ComfyUI_frontend that referenced this pull request Apr 22, 2026
…gate

Align with Comfy-Org/ComfyUI-Manager#2818 (shipped in 4.2.0) and
Comfy-Org/ComfyUI-Manager#2820 (shipped in 4.2.1).

Service layer:
- Convert START_QUEUE, UPDATE_ALL, UPDATE_COMFYUI, REBOOT to POST with
  body=null and preserved query params. Request shape compatible with
  the reject_simple_form_post gate (body=null + axios default
  application/json header is allowed).

UI/state layer (useManagerState):
- Add ManagerUIState.INCOMPATIBLE triggered when the Manager backend
  does not advertise extension.manager.supports_csrf_post. Treated as
  "not installed" — Manager buttons hide via shouldShowManagerButtons.
- One-shot upgrade toast via watch(immediate:true) with a module-level
  guard; openManager() re-emits the toast on explicit user action.
- i18n (en/ko) for the upgrade-required notification.

Refs: Comfy-Org/ComfyUI-Manager#2818, Comfy-Org/ComfyUI-Manager#2820
@ltdrdata ltdrdata closed this Apr 22, 2026
@ltdrdata ltdrdata deleted the fix/csrf-post-feature-flag branch April 22, 2026 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant