You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[HOLD for payment 2023-07-26] [$1000] Web - UserB can access the room "Welcome message" page and update it without permission #22013
Open a different browser and login to userB's account
Join the room by pasting the room URL
Now copy the “Welcome message” page URL from userA account
Paste it on userB’s browser
Update the "Welcome message"
Now copy the room URL from userA's account
Paste the URL in another browser
Expected Result:
UserB should be unable to access the "Welcome message" page and should not be able to modify it
Actual Result:
UserB can access the "Welcome message" page and update it without permission
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Android / native
Android / Chrome
iOS / native
iOS / Safari
MacOS / Chrome / Safari
MacOS / Desktop
Version Number: 1.3.34-1 Reproducible in staging?: y Reproducible in production?: y If this was caught during regression testing, add the test name, ID and link from TestRail: Email or phone of affected tester (no customers): Logs:https://stackoverflow.com/c/expensify/questions/4856 Notes/Photos/Videos: Any additional supporting documentation
We should also do this for settings like who can post and room name.
Currently, we allow the user to see the edit room name page, but there is an error as soon as we try to change the name from the backend. I believe we should add this backend functionality to all other settings (like who can post, welcome message) also while adding the front-end safeguards proposed above.
Looks like something related to react-navigation may have been mentioned in this issue discussion.
As a reminder, please make sure that all proposals are not workarounds and that any and all attempt to fix the issue holistically have been made before proceeding with a solution. Proposals to change our DeprecatedCustomActions.js files should not be accepted.
Please re-state the problem that we are trying to solve in this issue.
Web - UserB can access the room "Welcome message" page and update it without permission
What is the root cause of that problem?
In current ReportWelcomeMessagePage we didn't have a check if current user has permission to open it, we only prevent it from ReportSettingsPage.
What changes do you think we should make in order to solve the problem?
Since we need to reuse this in few other places, the best way to reuse the logic is to write a HOC. Let's call it withPolicyAdmin, we will wrap this HOC with any page that only can be access by admin user ie: Welcome message, who can post....etc.
importPropTypesfrom'prop-types';importReactfrom'react';import{withOnyx}from'react-native-onyx';import_from'underscore';importgetComponentDisplayNamefrom'../../../libs/getComponentDisplayName';importNotFoundPagefrom'../../ErrorPage/NotFoundPage';importONYXKEYSfrom'../../../ONYXKEYS';importreportPropTypesfrom'../../reportPropTypes';importFullscreenLoadingIndicatorfrom'../../../components/FullscreenLoadingIndicator';import*asReportUtilsfrom'../../../libs/ReportUtils';import*asPolicyUtilsfrom"../../../libs/PolicyUtils";exportdefaultfunction(WrappedComponent){constpropTypes={/** The HOC takes an optional ref as a prop and passes it as a ref to the wrapped component. * That way, if a ref is passed to a component wrapped in the HOC, the ref is a reference to the wrapped component, not the HOC. */forwardedRef: PropTypes.func,/** The report currently being looked at */report: reportPropTypes,/** The policies which the user has access to */policies: PropTypes.objectOf(PropTypes.shape({/** The policy name */name: PropTypes.string,/** The type of the policy */type: PropTypes.string,}),),/** Beta features list */betas: PropTypes.arrayOf(PropTypes.string),/** Indicated whether the report data is loading */isLoadingReportData: PropTypes.bool,};constdefaultProps={forwardedRef: ()=>{},report: {},policies: {},betas: [],isLoadingReportData: true,};// eslint-disable-next-line rulesdir/no-negated-variablesfunctionWithPolicyAdmin(props){if(props.isLoadingReportData&&(_.isEmpty(props.report)||!props.report.reportID)){return<FullscreenLoadingIndicator/>;}// if we don't have permission, show not found page.if(_.isEmpty(props.report)||!props.report.reportID||!ReportUtils.canAccessReport(props.report,props.policies,props.betas)||!PolicyUtils.isPolicyAdmin(props.policy)){return<NotFoundPage/>;}constrest=_.omit(props,['forwardedRef']);return(<WrappedComponent// eslint-disable-next-line react/jsx-props-no-spreading{...rest}ref={props.forwardedRef}/>);}WithPolicyAdmin.propTypes=propTypes;WithPolicyAdmin.defaultProps=defaultProps;WithPolicyAdmin.displayName=`withPolicyAdmin(${getComponentDisplayName(WrappedComponent)})`;// eslint-disable-next-line rulesdir/no-negated-variablesconstwithPolicyAdmin=React.forwardRef((props,ref)=>(<WithPolicyAdmin// eslint-disable-next-line react/jsx-props-no-spreading{...props}forwardedRef={ref}/>));returnwithOnyx({report: {key: ({route})=>`${ONYXKEYS.COLLECTION.REPORT}${route.params.reportID}`,},isLoadingReportData: {key: ONYXKEYS.IS_LOADING_REPORT_DATA,},betas: {key: ONYXKEYS.BETAS,},policies: {key: ONYXKEYS.COLLECTION.POLICY,},})(withPolicyAdmin);}
Since this logic will cover withReportOrNotFound we can deprecate it.
What alternative solutions did you explore? (Optional)
changed the title [-]Web - UserB can access the room "Welcome message" page and update it without permission[/-][+][$1000] Web - UserB can access the room "Welcome message" page and update it without permission[/+]on Jul 3, 2023
The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.42-26 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
If no regressions arise, payment will be issued on 2023-07-26. 🎊
After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.
BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:
[@mollfpr] The PR that introduced the bug has been identified. Link to the PR:
[@mollfpr] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
[@mollfpr] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
[@mollfpr] Determine if we should create a regression test for this bug.
[@mollfpr] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
[@puneetlath] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:
[@mollfpr] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
[@mollfpr] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
The regression step should be enough.
[@mollfpr] Determine if we should create a regression test for this bug.
[@mollfpr] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
Test Setup
From account A, create a new workspace.
Invite account B.
Create a workspace from account B.
Therefore, B is an admin in workspace B and not workspace A.
We need to prepare a chat with deep links to the correct page for testing. This setup can be done once on web, and then can be tested on other platforms with the same account.
✅ The page will open
❌ The not found page will be open Please look at the 'Test Setup (Web)' in the screenshots section to ensure steps are followed correctly.
We first need to copy the reportID of #announce of workspace A and workspace B then also #admin of workspace B. This can be done by opening the room and copying the number in the URL localhost:8080/r/[reportID].
[#announce B] means the reportID of the #announce room of workspace B. The same format applies for all other reportIDs copied.
Activity
esh-g commentedon Jul 1, 2023
Proposal
Please re-state the problem
Unauthorized users are able to edit the welcome message of the workspace room.
What is the root cause of that problem?
The root cause is that there are no checks in place either on the backend or the front-end if the user has access to the workspace as an admin.
What changes do you think we should make to solve this problem?
On the front-end, we should prevent the user from accessing the
welcomeMessagepage if the user is not an admin of the workspace.First we need to add the
withOnyxHOC to access thepolicyinReportWelcomeMessagePage.js:Here are the possible approaches:
Option 1
We can add a
userEffecthook to check if the user is admin and if they not, just navigate them back like this:Option 2
We are already using
FullPageNotFoundViewand we can add an additional condition for that as follows:Additional Note
We should also do this for settings like
who can postandroom name.Currently, we allow the user to see the edit room name page, but there is an error as soon as we try to change the name from the backend. I believe we should add this backend functionality to all other settings (like
who can post,welcome message) also while adding the front-end safeguards proposed above.What other approach did you explore
melvin-bot commentedon Jul 1, 2023
Looks like something related to
react-navigationmay have been mentioned in this issue discussion.As a reminder, please make sure that all proposals are not workarounds and that any and all attempt to fix the issue holistically have been made before proceeding with a solution. Proposals to change our
DeprecatedCustomActions.jsfiles should not be accepted.Feel free to drop a note in #expensify-open-source with any questions.
melvin-bot commentedon Jul 1, 2023
Triggered auto assignment to @puneetlath (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.melvin-bot commentedon Jul 1, 2023
Bug0 Triage Checklist (Main S/O)
Platformsin OP are ✅)hungvu193 commentedon Jul 1, 2023
Proposal
Please re-state the problem that we are trying to solve in this issue.
Web - UserB can access the room "Welcome message" page and update it without permission
What is the root cause of that problem?
In current
ReportWelcomeMessagePagewe didn't have a check if current user has permission to open it, we only prevent it fromReportSettingsPage.What changes do you think we should make in order to solve the problem?
Since we need to reuse this in few other places, the best way to reuse the logic is to write a HOC. Let's call it
withPolicyAdmin, we will wrap this HOC with any page that only can be access by admin user ie: Welcome message, who can post....etc.Since this logic will cover
withReportOrNotFoundwe can deprecate it.What alternative solutions did you explore? (Optional)
N/A
puneetlath commentedon Jul 3, 2023
Interesting. I agree that we need to restrict this from both the front-end and back-end.
[-]Web - UserB can access the room "Welcome message" page and update it without permission[/-][+][$1000] Web - UserB can access the room "Welcome message" page and update it without permission[/+]melvin-bot commentedon Jul 3, 2023
Job added to Upwork: https://www.upwork.com/jobs/~0112e180fbc88a066d
32 remaining items
melvin-bot commentedon Jul 19, 2023
Reviewinglabel has been removed, please complete the "BugZero Checklist".melvin-bot commentedon Jul 19, 2023
The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.42-26 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
If no regressions arise, payment will be issued on 2023-07-26. 🎊
After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.
As a reminder, here are the bonuses/penalties that should be applied for any External issue:
melvin-bot commentedon Jul 19, 2023
BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:
puneetlath commentedon Jul 24, 2023
Looks like everyone has had contracts sent.
@mollfpr friendly reminder on the checklist.
puneetlath commentedon Jul 27, 2023
Issue reporter: @ayazhussain79 $250
Contributor: @esh-g $1500 (including bonus)
C+: @mollfpr $1500 (including bonus)
I've paid the first two. @mollfpr just waiting on the checklist for you.
mollfpr commentedon Jul 31, 2023
Sorry, I swear I already complete the checklist of the issues near the payment date 😅
#18662
#21857
https://github.com/Expensify/App/pull/18662/files#r1278793008
https://github.com/Expensify/App/pull/21857/files#r1278797201
The regression step should be enough.
Test Setup
Therefore, B is an admin in workspace B and not workspace A.
We need to prepare a chat with deep links to the correct page for testing. This setup can be done once on web, and then can be tested on other platforms with the same account.
✅ The page will open
❌ The not found page will be open
Please look at the 'Test Setup (Web)' in the screenshots section to ensure steps are followed correctly.
We first need to copy the reportID of #announce of workspace A and workspace B then also #admin of workspace B. This can be done by opening the room and copying the number in the URL localhost:8080/r/[reportID].
[#announce B] means the reportID of the #announce room of workspace B. The same format applies for all other reportIDs copied.
Go to any chat on account B.
Add a comment 'Welcome message as admin' and add a link like this: https://staging.new.expensify.com/r/[#announce B]/welcomeMessage ✅
Add another comment 'Welcome message not as admin' and add a link like this: https://staging.new.expensify.com/r/[#announce A]/welcomeMessage. ❌
Add another comment 'Who can post (in #admin)' and add this a link like this: https://staging.new.expensify.com/r/[#admin B]/settings-who-can-post. ❌
Add another comment 'Who can post (as admin)' and add a link like this: https://staging.new.expensify.com/r/[#announce B]/settings/who-can-post. ✅
Add another comment 'Who can post (not as admin)' and add a link like this: https://staging.new.expensify.com/r/[#announce A]/settings/who-can-post. ❌
Click on each link and verify that it opens correctly according to ✅ and ❌.
puneetlath commentedon Jul 31, 2023
Great, thanks. Paid!