| Summary: | perl-HTTP-Tiny: error checking in mirror sub | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | Red Hat Enterprise Linux 7 | Reporter: | Florian Weimer <fweimer> | ||||||
| Component: | perl-HTTP-Tiny | Assignee: | perl-maint-list | ||||||
| Status: | CLOSED CURRENTRELEASE | QA Contact: | Martin Kyral <mkyral> | ||||||
| Severity: | unspecified | Docs Contact: | |||||||
| Priority: | unspecified | ||||||||
| Version: | 7.0 | CC: | mkyral, ppisar | ||||||
| Target Milestone: | rc | Keywords: | Patch | ||||||
| Target Release: | --- | ||||||||
| Hardware: | Unspecified | ||||||||
| OS: | Unspecified | ||||||||
| Whiteboard: | |||||||||
| Fixed In Version: | perl-HTTP-Tiny-0.033-2.el7 | Doc Type: | Bug Fix | ||||||
| Doc Text: |
Cause:
Calling mirror() method on HTTP::Tiny Perl object.
Consequence:
If a file with the same name as an HTTP::Tiny temporary
files exists, the file will get overwritten and possibly
abused with a symlink attack. If write into a temporary
file fails, the error will be silently ignored.
Fix:
A fix to use exclusive file creation and a fix to throw
an exception on write error have been applied to the
HTTP::Tiny library.
Result:
It's not possible to attack the HTTP::Tiny mirror()
subroutine with a symlink attack. Any write error is
reported by an exception.
|
Story Points: | --- | ||||||
| Clone Of: | Environment: | ||||||||
| Last Closed: | 2014-06-12 07:48:26 UTC | Type: | Bug | ||||||
| Regression: | --- | Mount Type: | --- | ||||||
| Documentation: | --- | CRM: | |||||||
| Verified Versions: | Category: | --- | |||||||
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||||
| Cloudforms Team: | --- | Target Upstream Version: | |||||||
| Bug Depends On: | |||||||||
| Bug Blocks: | 1031095 | ||||||||
| Attachments: |
|
||||||||
Created attachment 829631 [details]
[PATCH] Croak on failed write into a file
The mirror() method saves a document into a file. Any error while
writing to the file, e.g. no disk space, was ignored. This patch fixes
it by croaking on such I/O error.
---
lib/HTTP/Tiny.pm | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
Created attachment 829632 [details]
[PATCH] Do not use already existing temporary files
mirror() method tries to create a new temporary file as can be
concluded by using random name.
To prevent from from attacks, one has to make sure the file does not
exist. This patch creates temporary files with O_CREAT|O_EXCL mode.
---
lib/HTTP/Tiny.pm | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
Patches submitted to upstream as: <https://github.com/chansen/p5-http-tiny/issues/32> <https://github.com/chansen/p5-http-tiny/issues/33> Upstream accepted the exclusive-open patch. Upstream refused the check-print-error patch because Perl close() seems to report even previous errors. Although I think the patch is useful to abort network transfer right at local I/O error to safe network resources. |
This print statement in the mirror sub needs error checking: 118 binmode $fh; 119 $args->{data_callback} = sub { print {$fh} $_[0] }; 120 my $response = $self->request('GET', $url, $args); Otherwise there is a risk of silent data loss in case of a full disk. In addition, you should open the temporary file in safe manner (with O_EXCL). I don't know what kind of dependencies would be acceptable for HTTP::Tiny, so it is difficult to make suggestions here.