Summary
A decorator ordering mistake in changedetection.io causes certain Flask routes to be registered without their intended authentication wrapper.
Because the framework's @route() decorator is applied inside the custom @login_optionally_required decorator, Flask binds the original undecorated function, silently disabling authentication and exposing endpoints that should require login.
Affected context
This vulnerability occurs in changedetection.io routes that are intended to be protected by the @login_optionally_required decorator.
In affected versions, @login_optionally_required is applied outside of @blueprint.route(), which in Flask means the routing layer never sees the wrapped (authenticated) function.
Any deployment relying on these routes for user-specific or sensitive operations may be impacted if it assumes that login is enforced at the framework level.
Exploit preconditions
- Attack surface: HTTP endpoints exposed by the changedetection.io application
- Required access: Network access to the affected routes (no prior authentication required)
- Trigger point: Direct invocation of routes that were intended to require optional or conditional login but are registered without the auth wrapper
- Why exploitation is possible: Flask's decorator ordering semantics cause
@blueprint.route()to register the original function before the authentication decorator is applied, so the authorization logic is never executed for those requests
Why this happens
The root cause is a misuse of Flask decorators, where the route registration decorator must be the outermost decorator for the framework to correctly associate a view function with a URL rule.
By placing @login_optionally_required outside of @blueprint.route(), the application wraps a function that Flask no longer calls, while Flask itself routes requests to the original unwrapped view.
This design flaw aligns with CWE-863: Incorrect Authorization, because the application intends to enforce authentication but fails to attach the authorization mechanism to the actual execution path of the protected endpoints.
Potential impact
- Unauthenticated users can access endpoints that were intended to require login
- Exposure of user-specific or sensitive configuration data
- Unauthorized modification of application settings or watch configurations
- Increased risk of data leakage or manipulation in multi-user deployments
General mitigation guidance
Effective mitigation focuses on ensuring that authorization logic is structurally attached to every protected endpoint and cannot be bypassed by framework nuances.
Common defensive patterns include:
- Ensuring routing decorators (e.g.,
@app.route,@blueprint.route) are applied last (outermost) so they register the fully wrapped function - Centralizing authentication and authorization in middleware, blueprints, or application-level before-request hooks rather than relying solely on per-route decorator order
- Defining explicit access control policies for each route and documenting which endpoints must always enforce authentication
- Implementing defense-in-depth by validating user identity and permissions within business logic, not only at the routing layer
- Using secure-by-default patterns where routes are private unless explicitly marked as public
How teams detect issues like this
Detecting this class of issue involves both code-level analysis and behavioral checks:
- Static analysis or linters that flag Flask routes where authorization decorators do not directly wrap the view function or where
@routeis not the outermost decorator - Code review guidelines that explicitly require checking decorator ordering on all view functions and verifying that protected endpoints are wrapped by authentication decorators
- Automated tests that attempt to access protected routes without authentication and assert that access is denied
- Runtime monitoring or security testing (e.g., integration tests, DAST) to scan for endpoints that respond successfully without login despite being documented as protected

