T05 · Unauthorized Access and Privilege Escalation
- Location
src/clinstagram/commands/_dispatch.py:162- Finding
Forced Backend Selection Bypasses Compliance Policy Enforcement
- Content
View full analysis
Vulnerability Details
File Location:
src/clinstagram/commands/_dispatch.py:162-169
Vulnerability Type: Compliance policy and access-control bypass
Risk Level: MediumVulnerable Code
python # Force backend override forced = ctx.obj.get("backend") if forced and forced.value != "auto": backend_name = forced.value else: router = _get_router(ctx) backend_name = router.route(feature) if backend_name is None:Technical Analysis
Automatic backend selection passes through
Router.route(), which applies both capability checks and compliance-policy restrictions. In contrast, an explicitly supplied backend, such as--backend private, is accepted directly without verifying:- Whether the selected backend is allowed by the configured compliance mode.
- Whether the backend advertises support for the requested feature.
- Whether private API access is prohibited under
official-only. - Whether the requested private operation is restricted under
hybrid-safe.
This means the documented
official-onlyguarantee of “Graph API only” is not enforced when a backend override is supplied. The separate growth-action gate protects only certain actions, such as follow, unfollow, like, unlike, and comment creation. It does not provide general enforcement for all private API operations or all mutations.Attack Path
- A user configures the Skill in
official-onlyorhybrid-safemode. - A private API session remains present in the OS keychain.
- An agent or user invokes a command with
--backend private. dispatch()assignsbackend_namedirectly from the forced option.Router.route()and its compliance checks are skipped._instantiate_backend()loads the stored private session.- The requested private API operation executes despite the configured restriction.
Impact Assessment
The bypass allows use of an unofficial Instagram private API out ...[truncated 481 chars]
- Remediation
View remediation
Remediation Suggestions
- Route both automatic and explicit backend selections through one policy-enforcement function.
- Add a public router method that accepts a requested backend and verifies both
can_backend_do(backend, feature)and compliance-mode authorization. - Reject a forced private backend under
official-only. - Under
hybrid-safe, permit the private backend only for features explicitly included inREAD_ONLY_FEATURES. - Return
ExitCode.POLICY_BLOCKEDfor compliance violations andExitCode.CAPABILITY_UNAVAILABLEwhen the selected backend does not implement the feature. - Consider deleting or disabling private sessions when switching to
official-only, or clearly offer that as an option. - Add regression tests covering forced private selection for every compliance mode, including mutation and read-only operations.
A safe structure would resemble:
python router = _get_router(ctx) forced = ctx.obj.get("backend") if forced and forced.value != "auto": backend_name = router.route_forced(feature, forced.value) else: backend_name = router.route(feature)route_forced()must reject the request unless both the capability matrix and compliance policy authorize it.
