Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1031096

Summary: perl-HTTP-Tiny: error checking in mirror sub
Product: Red Hat Enterprise Linux 7 Reporter: Florian Weimer <fweimer>
Component: perl-HTTP-TinyAssignee: perl-maint-list
Status: CLOSED CURRENTRELEASE QA Contact: Martin Kyral <mkyral>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.0CC: mkyral, ppisar
Target Milestone: rcKeywords: 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:
Embargoed:
Bug Depends On:    
Bug Blocks: 1031095    
Attachments:
Description Flags
[PATCH] Croak on failed write into a file
none
[PATCH] Do not use already existing temporary files none

Description Florian Weimer 2013-11-15 15:34:34 UTC
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.

Comment 2 Petr Pisar 2013-11-27 10:08:00 UTC
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(-)

Comment 3 Petr Pisar 2013-11-27 10:08:15 UTC
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(-)

Comment 4 Petr Pisar 2013-11-27 10:15:07 UTC
Patches submitted to upstream as:

<https://github.com/chansen/p5-http-tiny/issues/32>
<https://github.com/chansen/p5-http-tiny/issues/33>

Comment 7 Petr Pisar 2013-12-10 15:38:58 UTC
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.