File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -85,7 +85,7 @@ function render_token_row( WP_User $user, Access_Token $token ) {
85
85
sprintf (
86
86
'<button class="button" name="oauth2_revoke" title="%s" value="%s">%s</button> ' ,
87
87
$ button_title ,
88
- esc_attr ( $ token ->get_key () ),
88
+ wp_create_nonce ( ' oauth2_revoke: ' . $ token -> get_key () ) . ' : ' . esc_attr ( $ token ->get_key () ),
89
89
esc_html__ ( 'Revoke ' , 'oauth2 ' )
90
90
),
91
91
];
@@ -138,7 +138,18 @@ function handle_revocation( $user_id ) {
138
138
return ;
139
139
}
140
140
141
- $ key = wp_unslash ( $ _POST ['oauth2_revoke ' ] );
141
+ $ data = wp_unslash ( $ _POST ['oauth2_revoke ' ] ); // WPCS: CSRF OK
142
+ if ( strpos ( $ data , ': ' ) === null ) {
143
+ return ;
144
+ }
145
+
146
+ // Split out nonce and check it.
147
+ list ( $ nonce , $ key ) = explode ( ': ' , $ data , 2 );
148
+ if ( ! wp_verify_nonce ( $ nonce , 'oauth2_revoke: ' . $ key ) ) {
149
+ wp_nonce_ays ( 'oauth2_revoke ' );
150
+ die ();
151
+ }
152
+
142
153
$ token = Access_Token::get_by_id ( $ key );
143
154
if ( empty ( $ token ) ) {
144
155
var_dump ( $ key , $ token );
You can’t perform that action at this time.
0 commit comments