-
-
Notifications
You must be signed in to change notification settings - Fork 77
Fix a vulnerability in Statistics.pm
and the macro PGstatisticsmacros.pl
.
#1220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Fix a vulnerability in Statistics.pm
and the macro PGstatisticsmacros.pl
.
#1220
Conversation
Attached are two problems to test this with. The The |
By the way, don't expect an immediate pull request for the third way that I know of that a problem can write a file wherever it wants to that the server has write permissions for. That one will take quite a bit more work. |
I see the second problem poses a problem and this fixes that. Just to clarify, Is the second problem as an example of using the |
The |
bdb8cff
to
6a4fb39
Compare
6a4fb39
to
f9029e0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Relooking after the other PR went it. Looks good.
…ros.pl`. This vulnerability allows a problem to write to any location or overwrite any file that the server has write permission to. The problem is that the `write_array_to_CSV` method of the `Statistics.pm` module takes a file name as its first argument and writes to that file without question. To fix this the method instead uses the new `WeBWorK::PG::IO::saveDataToFile` method which refuses to write anything outside of the html temporary directory. Note that the `make_csv_alias` method of the `Statistics.pm` module was dropped because it uses an invalid approach to creating a unique file name and is not needed. So there is no need for the `Statistics` package to even be an object. Now there is just the method `write_array_to_CSV`. Previously the `insertDataLink` method of `PGstatisticsmacros.pl` accepted the `$PG` object for its first argument. That first argument is still accepted, but is dropped if given, and there is no need to pass that argument anymore. The macro has direct access to the `$PG` variable so it is not a needed parameter. Also, a new optional last argument to the `insertDataLink` is accepted. If provide this argument must be a reference to a hash, and the key/value pairs in that hash will be added as attributes to the HTML `a` tak that is returned. If this parameter is not provided or it is but does not contain a `download` attribute, then a default `download` attribute with value `data.csv` will be added. Note that the `insertDataLink` method is not used by any problem in the OPL or Contrib. Furthermore, nothing in the `Statistics.pm` module is directly used by any problem in OPL or Contrib. Backwards compatibility is maintained for the `insertDataLink` method for anyone that may have been using it, but not for the `Statistics.pm` module. It was not intended that the module be used directly anyway. This fixes the second of the three ways that I know of for a problem to directly write to anywhere that the server has permission to do so.
f9029e0
to
7d32d6e
Compare
Fix a vulnerability in
Statistics.pm
and the macroPGstatisticsmacros.pl
.This vulnerability allows a problem to write to any location or overwrite any file that the server has write permission to.
The problem is that the
write_array_to_CSV
method of theStatistics.pm
module takes a file name as its first argument and writes to that file without question.To fix this the method instead uses the new
WeBWorK::PG::IO::saveDataToFile
method added in #1219 which refuses to write anything outside of the html temporary directory.Note that the
make_csv_alias
method of theStatistics.pm
module was dropped because it uses an invalid approach to creating a unique file name and is not needed. So there is no need for theStatistics
package to even be an object. Now there is just the methodwrite_array_to_CSV
.Previously the
insertDataLink
method ofPGstatisticsmacros.pl
accepted the$PG
object for its first argument. That first argument is still accepted, but is dropped if given, and there is no need to pass that argument anymore. The macro has direct access to the$PG
variable so it is not a needed parameter.Also, a new optional last argument to the
insertDataLink
is accepted. If provide this argument must be a reference to a hash, and the key/value pairs in that hash will be added as attributes to the HTMLa
tak that is returned. If this parameter is not provided or it is but does not contain adownload
attribute, then a defaultdownload
attribute with valuedata.csv
will be added.Note that the
insertDataLink
method is not used by any problem in the OPL or Contrib. Furthermore, nothing in theStatistics.pm
module is directly used by any problem in OPL or Contrib. Backwards compatibility is maintained for theinsertDataLink
method for anyone that may have been using it, but not for theStatistics.pm
module. It was not intended that the module be used directly anyway.This fixes the second of the three ways that I know of for a problem to directly write to anywhere that the server has permission to do so.