Skip to content

GH Issue #1444: Improve permission checking on secure message replies - #8128

Merged
labkey-adam merged 8 commits into
developfrom
fb_secure_reply_perms_1444
Oct 14, 2026
Merged

labkey-adam merged 8 commits into
developfrom
fb_secure_reply_perms_1444

Conversation

@labkey-adam

@labkey-adam labkey-adam commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Rationale

Prevent users who aren't on a secure thread's member list from replying to it, and stop API replies and edits from clearing a thread's member list. See GH Issue 1444.

Changes

  • Replies through the UI and API now require permission to respond to the parent thread
  • Replies must target the thread itself, not one of its responses
  • API replies and edits keep the thread's existing member list
  • Integration tests

@labkey-adam

labkey-adam commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor Author

For manual testing, attempt to POST to this URL, changing the parent value to an existing secure message's GUID. It should reject users who can't read the thread and accept users who can.

announcements-createThread.view?reply=true&thread.title=Reply&thread.body=reply%20body&thread.parent=87ac235b-a0e6-103f-a1e7-a9bb95f66820

Looks like this action requires a non-JSON post, which the query-apiTest.view page doesn't support. To test, I commented out the line that sets content-type to application/json (line 242) in apiTest.jsp.

@labkey-adam labkey-adam changed the title GH Issue 1444: Improve permission checking on secure message replies GH Issue #1444: Improve permission checking on secure message replies Oct 3, 2026
@labkey-bpatel

Copy link
Copy Markdown
Contributor

Manual test findings:

Note: These findings are all around the message board APIs (createThread.api and updateThread.api). Since users can call these APIs directly, perhaps they should follow the same rules as the UI.

Test findings 1 and 2 below show places where the API behaves differently from the UI. Test finding 3 is a side effect where an API edit unexpectedly changes the saved notify list.

Setup

  1. Create three users: Jim, Michael and Creed.
  2. Create two folders, each with a Messages web part. Configure each one in Messages › Admin (Customize):
    a) SecureBoard: Security = On without email; Include Notify List checked. Roles: Jim and Michael are Message Board Contributors.
    b) OpenBoard: Security = Off; Include Notify List checked. Roles: Jim and Creed are Message Board Contributors.
  3. API calls are made from the browser devtools console on a page in the step's folder, as the user the step names. Paste this helper again after each page load or impersonation change:
    function call(action, params) {
    LABKEY.Ajax.request({
    url: LABKEY.ActionURL.buildURL('announcements', action + '.api'),
    method: 'POST', params,
    success: r => console.log(r.status, r.responseText),
    failure: r => console.log(r.status, r.responseText)
    });
    }
  4. Use this query to see each post's RowId, EntityId and saved notify list:
    SELECT a.RowId, t.Title AS thread,
    CASE WHEN a.Parent IS NULL THEN 'original' ELSE 'response' END AS post,
    a.EntityId, a.Created,
    string_agg(p.Name, ', ' ORDER BY p.Name) AS notify_list
    FROM comm.Announcements a
    JOIN comm.Announcements t ON t.EntityId = COALESCE(a.Parent, a.EntityId)
    LEFT JOIN comm.UserList u ON u.MessageId = a.RowId
    LEFT JOIN core.Principals p ON p.UserId = u.UserId
    GROUP BY a.RowId, t.Title
    ORDER BY a.RowId;

Test findings

  1. createThread.api doesn't check that you're replying to the original message, like the UI does
    Folder: SecureBoard
  1. As admin, create Message 1 and notify Jim.
  2. As Jim, reply to Message 1 through the API:
    call('createThread', {reply:true, 'thread.parent':'<Message 1 EntityId>', 'thread.title':'x', 'thread.body':'x'})
    Result: 200. Jim's reply shows notify list = Jim.
  3. As admin, respond to Message 1 with Notify cleared. The admin's response has an empty notify list. Jim's reply still lists Jim, but that list is now out of date.
  4. As Jim, try to reply:
    • UI, with Jim's reply as the parent: announcements-respond.view?parentId=<Jim's reply EntityId> returns 404, "Could not find message."
    • UI, with Message 1 as the parent: announcements-respond.view?parentId=<Message 1 EntityId> returns a permission error.
    • API, with Jim's reply as the parent: call('createThread', {reply:true, 'thread.parent':'<Jim's reply EntityId>', 'thread.title':'x', 'thread.body':'x'}) returns 400, "Failed to reply to thread. Could not locate most recent response for thread …"
  5. SELECT RowId, LatestId FROM comm.Threads WHERE RowId IN (<Message 1 RowId>, <Jim's reply RowId>);
    This returns only Message 1, with the admin's response as its LatestId. There is no row for Jim's reply, which is the only reason the API call in step 4 fails.

Expected: The API explicitly rejects Jim's reply as a reply parent, the same way the UI does (404, "Could not find message").

2) API replies drop notify-list members who temporarily can't read the thread, permanently and without saying so
Folder: SecureBoard

  1. As admin, create Message 2 and notify Jim and Michael. The query shows notify list = Jim, Michael.
  2. As admin, deactivate Michael (Admin › Site › Site Users).
  3. UI: As Jim, respond to Message 2, leave the prefilled Notify list as it is, and submit.
    Result: rejected with "Can't add Michael to the member list: This user doesn't have permission to read the thread." Nothing is saved.
  4. API: As Jim, reply to Message 2:
    call('createThread', {reply:true, 'thread.parent':'<Message 2 EntityId>', 'thread.title':'api', 'thread.body':'api'})
    Result: 200, and nothing in the response mentions Michael.
  5. Run the query. The new response's notify list = Jim. Michael was removed.
  6. As admin, reactivate Michael.
  7. As Michael, open SecureBoard. No messages are listed. SELECT RowId, LatestId FROM comm.Threads WHERE RowId = <Message 2 RowId>; shows that Message 2's latest post is Jim's API reply, whose notify list doesn't include Michael.

Expected: The UI and API handle a member who can't read the thread the same way. The API doesn't remove someone without saying so.

  1. API edit overwrites the original message's saved notify list with the latest response's list

Folder: OpenBoard

  1. As admin, create Message 3 and notify Jim and Creed. The query shows original notify list = Jim, Creed.
  2. As admin, respond to Message 3 and notify Jim only. The query shows response notify list = Jim.
  3. As admin, edit only the original message's body through the API:
    call('updateThread', {'thread.rowId': <Message 3 RowId>, 'thread.body': 'edited via api'})
    Result: 200, and only the body changed.
  4. Run the query again:
    • The original Message 3 changed from Jim, Creed to Jim.
    • The response is unchanged (Jim).

Expected: Editing only the body leaves the original message's notify list unchanged (Jim, Creed).

@labkey-adam

labkey-adam commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor Author

@labkey-bpatel, thanks for the feedback. Here are Claude's responses:

I went through the three API concerns in the tester's comment on #8128. One is a real bug from the PR. The other two are not security gaps, but each is worth a small change.

  1. createThread.api accepts a reply's EntityId as the parent — rejected already, just less clearly
    Not a security gap. In comm-create.sql (around line 30), the comm.Threads view only has rows for top-level posts (WHERE parents.parent IS NULL). A response never
    has a LatestId, so getLatestPostId() returns null and CreateThreadAction always fails with the 400 the tester saw. This happens before the allowResponse() check,so no reply-to-a-reply can get through.
    The tester is still right that the code makes the reader infer this. RespondAction and BaseInsertAction now reject a parent that is itself a reply, but the API
    path doesn't.
    Recommendation: in CreateThreadAction, treat a parentThread that is itself a reply the same as "Unable to find parent thread". That adds one condition, matches theUI, and drops the confusing "Could not locate most recent response" message.

  2. API replies silently drop members who can't read the thread — a deliberate tradeoff
    getRetainedMemberListInput() does this on purpose. The API has no way to send a member list (copyEditableProps never copies memberListInput), so the caller can't fix a bad list. If the API rejected the post the way the UI does, nobody could reply to or edit that thread through the API until someone fixed the list in the UI. In the UI, Jim can only submit by deleting Michael from the Notify box, which ends in the same state the API reaches: Michael is off the list. What differs is that the API doesn't tell anyone. Before this PR the API reply cleared the whole member list silently, so the PR is already strictly better. Recommendation: keep the pruning. If the tester wants parity on "saying so", the API response could list the users it dropped, which is a small additive change. I wouldn't switch to rejecting.

  3. API edit copies the latest response's member list onto the original post — a real bug This one is right, and the PR introduced it. AnnouncementModel.getMemberListIds() goes through AnnouncementManager.getMemberList(), which reads the list from tthread's latest post (via getLatestPostId). UpdateThreadAction passes that list to updateAnnouncement, which saves it on the original's own row. Before the PR, the same edit cleared the original's list instead, so it never preserved the list either.
    How much it matters: limited. A thread's current member list always comes from its latest post, so the original's own list only matters as history, or if every response is later deleted and the original becomes the latest post again.
    The UI does the same thing. The edit form's UpdateBean fills the Notify box from ann.getMemberListIds(), i.e. the latest post's list, and saves it onto the edited post. So this matches the UI rather than diverging from it.
    Recommendation: fix the API path. In UpdateThreadAction, carry forward the edited post's own stored list (comm.UserList WHERE MessageId = rowId), using a small manager method, instead of getMemberListIds(). When the edited post is the latest one, the two lists are the same, so the existing tests still hold. Add a test for "original with a response, edit body, original's list unchanged". The matching UI quirk predates this PR and is out of scope.

@labkey-adam

Copy link
Copy Markdown
Contributor Author

Based on this, I made the recommended changes for #1 and #3, and left #2 alone. Let me know if you want to discuss.

@labkey-bpatel labkey-bpatel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Retested 1 and 3, looks good!

@labkey-adam
labkey-adam merged commit e9ddcb8 into develop Oct 14, 2026
7 checks passed
@labkey-adam
labkey-adam deleted the fb_secure_reply_perms_1444 branch October 14, 2026 00:49
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