Skip to content

ipc: fix D-Bus action denylist bypass via URL path/query ambiguity#1343

Open
acts-1631 wants to merge 1 commit into
crosswire:masterfrom
acts-1631:fix/ipc-action-denylist-bypass
Open

ipc: fix D-Bus action denylist bypass via URL path/query ambiguity#1343
acts-1631 wants to merge 1 commit into
crosswire:masterfrom
acts-1631:fix/ipc-action-denylist-bypass

Conversation

@acts-1631

Copy link
Copy Markdown

ipc_object_set_current_reference() rejects setCurrentReference calls that
request the showStudypad or showImage actions, since those touch the local
filesystem or spawn external programs and the D-Bus session bus is
reachable by any local peer.

The check extracted the action value with strstr(reference, "action=") on
the raw reference, but main_url_handler() splits the URL at the first '?'
and asks Sword's URL class to parse the action from the query string only.
A reference such as

passagestudy.jsp/action=showBookmark?action=showImage&value=evil.png

has "action=showBookmark" appear first in the URL path, so the raw
strstr() picks that up (and it doesn't match the denylist), while Sword's
parser only looks at the query string after the '?' and resolves the real
action to showImage, which then gets dispatched.

This fixes it by not re-implementing URL/query parsing a second time in
ipc.c. The re-encoding + Sword URL parsing that main_url_handler() already
uses for dispatch is factored out into main_url_get_action(), and the IPC
gate calls that instead. The check and the actual dispatch now always
agree, since they're the same code path.

ipc_object_set_current_reference() rejects setCurrentReference calls
that request the showStudypad or showImage actions, since those touch
the local filesystem or spawn external programs and the D-Bus session
bus is reachable by any local peer.

The check extracted the action value with strstr(reference, "action=")
on the raw reference, but main_url_handler() splits the URL at the
first '?' and asks Sword's URL class to parse the action from the
query string only. A reference such as

  passagestudy.jsp/action=showBookmark?action=showImage&value=evil.png

has "action=showBookmark" appear first in the URL path, so the raw
strstr() picks that up (and it doesn't match the denylist), while
Sword's parser only looks at the query string after the '?' and
resolves the real action to showImage, which then gets dispatched.

Fix this by not re-implementing URL/query parsing a second time in
ipc.c. Factor the re-encoding + Sword URL parsing that
main_url_handler() already uses for dispatch into
main_url_get_action(), and have the IPC gate call that instead. The
check and the actual dispatch now always agree, since they're the same
code path, so this class of parsing-asymmetry bypass isn't possible
regardless of how the URL is structured.
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