Opened 7 years ago
Closed 4 days ago
#13377 closed defect (bug) (fixed)
Add more sanitization in _cleanup_header_comment
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 4.8.2 | Priority: | normal |
| Severity: | normal | Version: | 3.0 |
| Component: | Security | Keywords: | |
| Focuses: | Cc: |
Description
The _cleanup_header_comment function is used in multiple places, but one in particular can cause some problems on the Page edit screen (or any screen that uses page templates). The get_page_templates function (which gets the list of page templates to display in a <select> box on the page edit screen) uses to cleanup the page templates retrieved from a file.
Unfortunately the function does not sanitize enough, and if (for instance) JavaScript existed in the page template name it would be run on the Page Edit screen.
To test, add some JavaScript (with <script> tags) to the "Template Name:" line of a page template, and load the Page edit screen.
Attachments (2)
Change History (24)
#3
@chriscct7
23 months ago
- Keywords needs-refresh added
#4
@Mte90
9 months ago
- Keywords dev-feedback added; needs-refresh removed
Patch refreshed but I am not sure if there are other part that require this sanitization because it is very old that ticket.
This ticket was mentioned in Slack in #core by mte90. View the logs.
2 weeks ago
#6
@johnbillion
5 days ago
- Milestone changed from Future Release to 4.8.2
- Owner set to johnbillion
- Status changed from assigned to reviewing
#7
@johnbillion
4 days ago
- Resolution set to fixed
- Status changed from reviewing to closed
In 41399:
#8
@johnbillion
4 days ago
- Keywords fixed-major added; has-patch dev-feedback removed
- Resolution fixed deleted
- Status changed from closed to reopened
#9
@johnbillion
4 days ago
In 41412:
#10
@johnbillion
4 days ago
In 41413:
#11
@johnbillion
4 days ago
In 41414:
#12
@johnbillion
4 days ago
In 41415:
#13
@johnbillion
4 days ago
In 41416:
#14
@johnbillion
4 days ago
In 41434:
#15
@johnbillion
4 days ago
In 41444:
#16
@johnbillion
4 days ago
In 41445:
#17
@johnbillion
4 days ago
In 41446:
#18
@johnbillion
4 days ago
In 41447:
#19
@johnbillion
4 days ago
In 41449:
#20
@johnbillion
4 days ago
In 41452:
#21
@johnbillion
4 days ago
In 41456:
It appears to be used in get_file_data() (which is sanitized properly where used), get_file_description() and get_page_templates().
The attached patch sanitizes uses of the latter two with esc_html(), apart from get_page_templates() in wp_getPageTemplates(). Not really sure what to do with that.
It also standardises trim() usage on get_file_description($file) and makes the $filedesc logic actually understandable.