Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't rewrite "self-addressed" privileged IQs as results. #4348

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mtstickney
Copy link

As described in #4347:

process_privilege_iq is meant to rewrite the result of a privileged IQ into the forwarded form required by XEP-0356 so it can be routed back to the original privileged requester. It checks whether the impersonated JID (ReplacedJid) of the original request matches the recipient of the IQ being processed to determine if this is a response to a a privileged IQ (assuming it has privileged-IQ metadata attached).

Unfortunately, it doesn't check the packet type, and this check will also match a privileged-IQ request that is being sent to the same user that's being impersonated. This results in the request itself being rewritten and forwarded back to the sending component, instead of being processed and having the result send back.

Instead, just check for IQ results (either a regular result or an error), and as long as it is marked as being a response to a privileged-IQ, always rewrite it and forward it to the sending component. There's no circumstance under which we shouldn't forward a privileged-IQ response, so we don't need to be tricky about checking whether impersonated-user and recipient match.

process_privilege_iq is meant to rewrite the result of a privileged IQ into
the forwarded form required by XEP-0356 so it can be routed back to the
original privileged requester. It checks whether the impersonated JID
(`ReplacedJid`) of the original request matches the recipient of the IQ
being processed to determine if this is a response to a a privileged IQ
(assuming it has privileged-IQ metadata attached).

Unfortunately, it doesn't check the packet type, and this check will also
match a privileged-IQ _request_ that is being sent to the same user that's
being impersonated. This results in the request itself being rewritten and
forwarded back to the sending component, instead of being processed and
having the result send back.

Instead, just check for IQ results (either a regular result or an error),
and as long as it is marked as being a response to a privileged-IQ, always
rewrite it and forward it to the sending component. There's no circumstance
under which we _shouldn't_ forward a privileged-IQ response, so we don't
need to be tricky about checking whether impersonated-user and recipient
match.
@coveralls
Copy link

Coverage Status

coverage: 33.384%. remained the same
when pulling 64142de on mtstickney:fix_privileged_iq_response_detection
into 76baf58 on processone:master.

@badlop badlop added this to the ejabberd 25.xx milestone Feb 7, 2025
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.

3 participants