Skip to content

Commit 18605ae

Browse files
jehervematticbot
authored andcommitted
Contact Form: improve security of the form endpoint (#39759)
* Contact Form: improve security of the form endpoint Ensure that submitted forms can only be accessed by logged in users with the necessary capabilities. Reference: p9dueE-8ng-p2 Co-authored-by: Chris Jean <[email protected]> * changelog --------- Co-authored-by: Chris Jean <[email protected]> Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/11323183689 Upstream-Ref: Automattic/jetpack@1a544bc
1 parent 0f52e8b commit 18605ae

File tree

7 files changed

+123
-113
lines changed

7 files changed

+123
-113
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ This is an alpha version! The changes listed here are not final.
1515
- Related Posts: allow Related Posts on non-post CPTs where the block is already able to be used.
1616

1717
### Bug fixes
18+
- Contact Form: ensure that submitted forms can only be accessed by logged in users allowed to view form submissions.
1819
- Fixed rendering of goodreads block when there is not id attribute so to not result in a PHP warning
1920
- General: Only include `wp-polyfill` as a script dependency when needed.
2021
- Newsletter: ensure `Enable featured image on your new post emails` setting displays the right value.

jetpack_vendor/automattic/jetpack-forms/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ This is an alpha version! The changes listed here are not final.
1313
- Only include `wp-polyfill` as a script dependency when needed.
1414
- Updated package dependencies.
1515

16+
### Fixed
17+
- Improve security of the form endpoint
18+
1619
## [0.33.2] - 2024-10-07
1720
### Changed
1821
- Updated package dependencies. [#39594]

jetpack_vendor/automattic/jetpack-forms/src/contact-form/class-contact-form-endpoint.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ class Contact_Form_Endpoint extends \WP_REST_Posts_Controller {
2222
* @return WP_Error|boolean
2323
*/
2424
public function get_items_permissions_check( $request ) { //phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
25+
if ( ! current_user_can( 'edit_pages' ) ) {
26+
return false;
27+
}
2528
if ( ! is_user_member_of_blog( get_current_user_id(), get_current_blog_id() ) ) {
2629
return new WP_Error(
2730
'rest_cannot_view',
@@ -40,6 +43,9 @@ public function get_items_permissions_check( $request ) { //phpcs:ignore Variabl
4043
* @return WP_Error|boolean
4144
*/
4245
public function get_item_permissions_check( $request ) { //phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
46+
if ( ! current_user_can( 'edit_pages' ) ) {
47+
return false;
48+
}
4349
if ( ! is_user_member_of_blog( get_current_user_id(), get_current_blog_id() ) ) {
4450
return new WP_Error(
4551
'rest_cannot_view',

jetpack_vendor/i18n-map.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
),
5151
'jetpack-forms' => array(
5252
'path' => 'jetpack_vendor/automattic/jetpack-forms',
53-
'ver' => '0.33.3-alpha1728575216',
53+
'ver' => '0.33.3-alpha1728892143',
5454
),
5555
'jetpack-image-cdn' => array(
5656
'path' => 'jetpack_vendor/automattic/jetpack-image-cdn',

0 commit comments

Comments
 (0)