{"action":"created","issue":{"url":"https://api.github.com/repos/gthomas2/moodle-filter_imageopt/issues/7","repository_url":"https://api.github.com/repos/gthomas2/moodle-filter_imageopt","labels_url":"https://api.github.com/repos/gthomas2/moodle-filter_imageopt/issues/7/labels{/name}","comments_url":"https://api.github.com/repos/gthomas2/moodle-filter_imageopt/issues/7/comments","events_url":"https://api.github.com/repos/gthomas2/moodle-filter_imageopt/issues/7/events","html_url":"https://github.com/gthomas2/moodle-filter_imageopt/issues/7","id":281642673,"number":7,"title":"Image security issue, all images are public and ignore capability checks","user":{"login":"brendanheywood","id":187449,"avatar_url":"https://avatars0.githubusercontent.com/u/187449?v=4","gravatar_id":"","url":"https://api.github.com/users/brendanheywood","html_url":"https://github.com/brendanheywood","followers_url":"https://api.github.com/users/brendanheywood/followers","following_url":"https://api.github.com/users/brendanheywood/following{/other_user}","gists_url":"https://api.github.com/users/brendanheywood/gists{/gist_id}","starred_url":"https://api.github.com/users/brendanheywood/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brendanheywood/subscriptions","organizations_url":"https://api.github.com/users/brendanheywood/orgs","repos_url":"https://api.github.com/users/brendanheywood/repos","events_url":"https://api.github.com/users/brendanheywood/events{/privacy}","received_events_url":"https://api.github.com/users/brendanheywood/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2017-12-13T06:51:43Z","updated_at":"2017-12-24T12:25:19Z","closed_at":null,"author_association":"NONE","body":"This filter is really cool and I really want to use - but I can't consider production ready because of the way the images are served.\r\n\r\nThe way it broadly works is:\r\n1) filter rewrites the img src which points back to *this* plugins file path\r\n2) browser asks *this* plugin for the new sized image\r\n3) image is resized on demand and served publicly with no capability checks\r\n\r\nThe way I think it should work is:\r\n\r\n1) filter detects unoptimized image with no alternate sizes, creates an ad hoc task, and then serves original image as-is un optimized. Cache this 'miss' in MUC for a very short time like 2 minutes (or don't cache at all). Some optimizations like the deferred scroll loading could still be performed on the original file.\r\n\r\n2) ad hoc tasks processes the image and resizes it and saves it *back into the original file area* and stores some metadata somewhere that the alternate sizes are available\r\n\r\n3) on a later page view, the filter detects the alternate sizes are now available and rewrites to refer to them instead. The urls point to the original file area. Cache this filter metadata lookup 'hit' in MUC for as long as possible.\r\n\r\n4) The original plugin (eg mod forum) serves the file and does all it's own checks to see if the student can actually see the file and then serves it.\r\n"},"comment":{"url":"https://api.github.com/repos/gthomas2/moodle-filter_imageopt/issues/comments/353781498","html_url":"https://github.com/gthomas2/moodle-filter_imageopt/issues/7#issuecomment-353781498","issue_url":"https://api.github.com/repos/gthomas2/moodle-filter_imageopt/issues/7","id":353781498,"user":{"login":"gthomas2","id":7324935,"avatar_url":"https://avatars2.githubusercontent.com/u/7324935?v=4","gravatar_id":"","url":"https://api.github.com/users/gthomas2","html_url":"https://github.com/gthomas2","followers_url":"https://api.github.com/users/gthomas2/followers","following_url":"https://api.github.com/users/gthomas2/following{/other_user}","gists_url":"https://api.github.com/users/gthomas2/gists{/gist_id}","starred_url":"https://api.github.com/users/gthomas2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gthomas2/subscriptions","organizations_url":"https://api.github.com/users/gthomas2/orgs","repos_url":"https://api.github.com/users/gthomas2/repos","events_url":"https://api.github.com/users/gthomas2/events{/privacy}","received_events_url":"https://api.github.com/users/gthomas2/received_events","type":"User","site_admin":false},"created_at":"2017-12-24T12:25:19Z","updated_at":"2017-12-24T12:25:19Z","author_association":"OWNER","body":"@brendanheywood - I've had a go at option 1:\r\n\r\nhttps://github.com/gthomas2/moodle-filter_imageopt/compare/issue7-fix-with-subdir?expand=1\r\n\r\nI'm putting the resized images in sub folders. In this way, even if you had 100s of different resized files it wouldn't confuse the user."}}
{"actor":{"display_login":"gthomas2"}}