Skip to content

[3.0] Answer a personal message link that points at nothing - #9464

Open
albertlast wants to merge 1 commit into
SimpleMachines:release-3.0from
albertlast:3.0/pm-unknown-pmid
Open

[3.0] Answer a personal message link that points at nothing#9464
albertlast wants to merge 1 commit into
SimpleMachines:release-3.0from
albertlast:3.0/pm-unknown-pmid

Conversation

@albertlast

Copy link
Copy Markdown
Collaborator

Description

Folder::show() assigns whatever PM::load() found straight to $requested_pm, which is a typed object property:

$this->requested_pm = current(PM::load((int) $_GET[$var]));

// Make sure you have access to this PM.
if (!$this->requested_pm->canAccess($this->is_inbox ? 'inbox' : 'sent')) {

PM::load() finds nothing for an ID that has been pruned or was never real, and current() answers false for that. So the request ends before the access check runs:

Cannot assign false to property SMF\PersonalMessage\Folder::$requested_pm of type object
url: /index.php?action=pm;f=inbox;pmid=999

A 500, for a stale bookmark or a link in an old notification — and PM pruning is a feature, so the IDs in those links do go away.

Behind that sits a second one. A pmid of 0, a negative number, or anything non-numeric all cast to 0, and PM::load() carries that as far as the database before failing:

Database error, given array of integer values is empty. (ids)<br>Function: get
url: /index.php?action=pm;f=inbox;pmid=abc

Another 500, for a URL a member only has to mistype. Fixing just the first leaves this one, so both are here.

Both now get the answer the check below them already gives for a PM belonging to somebody else.

url before after
pmid=999 500, TypeError 403, no access
pmsg=999 500, TypeError 403, no access
pmid=0 500, database error 403, no access
pmid=abc 500, database error 403, no access
pmid=-5 500, database error 403, no access
pmid=1 (a real one) 200 200

The inbox, the sent folder, a real pmid and a quote form all still render, with nothing added to smf_log_errors.

Issues References (Fixes|Related|Closes)

n/a

Folder::show() assigned whatever PM::load() found straight to
$requested_pm, which is a typed object property:

    $this->requested_pm = current(PM::load((int) $_GET[$var]));

PM::load() finds nothing for an ID that was pruned or was never real, and
current() answers false for that, so the page ends with "Cannot assign
false to property SMF\PersonalMessage\Folder::$requested_pm of type
object" - a 500 for a stale bookmark or a link in an old notification.

Behind that sits a second one. A pmid of 0, a negative number or anything
non-numeric casts to 0, and PM::load() takes that as far as the database
before failing with "given array of integer values is empty", which is
another 500 for a URL a member only has to mistype.

Both now get the answer the check below them already gives a PM that
belongs to somebody else: you are not allowed to access this section.

Signed-off-by: Mathias Albert <mathiaspapealbert@hotmail.com>
Signed-off-by: albertlast <mathiaspapealbert@hotmail.com>
@jdarwood007 jdarwood007 added the PM label Aug 9, 2026
@jdarwood007 jdarwood007 added this to the 3.0 Alpha 6 milestone Aug 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants