Skip to content

Commit e3eb17d

Browse files
committed
FOUR-24634 Business Logic Flaw Allows Admin API Token Generation
1 parent b0911b7 commit e3eb17d

3 files changed

Lines changed: 9 additions & 2 deletions

File tree

‎ProcessMaker/Http/Controllers/Admin/UserController.php‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace ProcessMaker\Http\Controllers\Admin;
44

55
use Illuminate\Contracts\View\Factory;
6+
use Illuminate\Support\Facades\Auth;
67
use Illuminate\View\View;
78
use ProcessMaker\Http\Controllers\Controller;
89
use ProcessMaker\Models\Group;
@@ -87,6 +88,9 @@ function ($result, $item) {
8788
$addons = $this->getPluginAddons('edit', compact(['user']));
8889
$addonsSettings = $this->getPluginAddons('edit.settings', compact(['user']));
8990

91+
// The user can only create tokens for themselves or if they are an administrator.
92+
$canCreateTokens = Auth::user()->is_administrator || Auth::user()->id === $user->id;
93+
9094
return view('admin.users.edit', compact(
9195
'user',
9296
'groups',
@@ -104,6 +108,7 @@ function ($result, $item) {
104108
'addons',
105109
'addonsSettings',
106110
'ssoUser',
111+
'canCreateTokens',
107112
));
108113
}
109114

‎ProcessMaker/Http/Controllers/Api/UserTokenController.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ public function index(Request $request, User $user)
141141
*/
142142
public function store(Request $request, User $user)
143143
{
144-
if (!Auth::user()->can('edit', $user)) {
144+
// The user can only create tokens for themselves or if they are an administrator.
145+
if (!Auth::user()->can('edit', $user) || !(Auth::user()->is_administrator || Auth::user()->id === $user->id)) {
145146
throw new AuthorizationException(__('Not authorized to update this user.'));
146147
}
147148

‎resources/views/admin/users/edit.blade.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
</div>
9595
<div class="tab-pane" id="nav-tokens" role="tabpanel" aria-labelledby="nav-tokens-tab">
9696
<div>
97-
<div class="d-flex justify-content-end mb-3">
97+
<div class="d-flex justify-content-end mb-3" v-if="canCreateTokens">
9898
<button type="button" aria-label="{{__('New Token')}}" class="btn btn-secondary" @click="generateToken">
9999
<i class="fas fa-plus"></i> {{__('Token')}}
100100
</button>
@@ -284,6 +284,7 @@
284284
focusErrors: 'errors',
285285
originalEmail: '',
286286
emailHasChanged: false,
287+
canCreateTokens: @json($canCreateTokens),
287288
}
288289
},
289290
created() {

0 commit comments

Comments
 (0)