Presigned URL redirects write a unique never read entry to core/htmlpurifier on every file request
@Alex-Accipio is already working on this.
Since Nov 3, 2026.
Assessment
- Difficulty
- 3/5
- Estimated time
- Half a day
- Newbie friendliness
- 62/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- aws, php
- Domain
- backend, performance
Research direction
Start in object_file_system::redirect_to_presigned_url() in classes/local/store/object_file_system.php, where the signed URL is passed to core redirect(). Check how core redirect() and clean_text() handle the URL, which is what writes the core/htmlpurifier cache entry. Reproduce by counting entries under cachestore_file core_htmlpurifier before and after several requests to a presigned fixture. Done when the redirect no longer writes to that cache and the presigned-URL tests still pass.
Written by the indexing model from the issue text.
Description
object_file_system::redirect_to_presigned_url() sends the signed URL through core redirect(). Core redirect() sanitises the target with clean_text(), and purify_html() caches the result in core/htmlpurifier keyed on the full input text with no TTL.
A presigned S3 url changes every second (X-Amz-Date, X-Amz-Signature) so every file request:
- writes a new ~1.5KB entry to
core/htmlpurifierthat is never read again - constructs an HTMLPurifier instance to sanitise a URL the AWS SDK generated
To reproduce:
- Configure S3 with presigned URLs enabled, whitelist *, minimum size 0.
- Open
/admin/tool/objectfs/presignedurl_tests.phponce so the fixtures files are pushed to the bucket - Count entries in the
core/htmlpurifierstore. With the default file store:
find <moodledata>/cache/cachestore_file/default_application/core_htmlpurifier -type f | wc -l - Request one fixture several times, one second apart, bypassing the browser cache:
for i in $(seq 1 10); do
curl -sk -o /dev/null -w '%{http_code}\n' -b "MoodleSession=<cookie>" \
"https://<site>/pluginfile.php/1/tool_objectfs/settings/0/testimage.png?forcedownload=1"
sleep 1
done
- Count again
Moodle could add a TTL for htmlpurifier but the TTL doesn't remove the unnecessary write. The URL is generated by the AWS SDK, not from user input, I'm not sure there is value in needing to run htmlpurify on this, so I think there should be a change in objectfs to send the redirect directly.
- Dominant language
- PHP
- Stars
- 102
- Forks
- 85
- Avg merge
- 4d 21h
- Merged PRs (30d)
- 1
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from catalyst/moodle-tool_objectfs
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
catalyst/moodle-tool_objectfs#717 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
catalyst/moodle-tool_objectfs#777 ·
-
TLS peer verification disabled on the pre-signed URL range request — should CURLOPT_SSL_VERIFYPEER be true?Possibly taken @PM84 claimed this 40 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
catalyst/moodle-tool_objectfs#770 ·
-
Difficulty 4/5 1-2 days Newbie friendliness 42/100
catalyst/moodle-tool_objectfs#761 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
catalyst/moodle-tool_objectfs#759 ·
All issues in catalyst/moodle-tool_objectfs
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
taskforcesh/bullmq#5238 ·
Maintainers usually reply within 1 day
-
[Bug] v-change-database-password reports success but doesn't change the password when MySQL validate_password rejects itPossibly taken @bfs2021 claimed this today. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Automattic/jetpack#55517 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 84/100
-
area/import type/enhancement when/later
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Maintainers usually reply within 1 day