Skip to content
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

[PATCH] Coverity: perlfunc: recommend chdir("/') after chroot #13772

Closed
p5pRT opened this issue Apr 26, 2014 · 16 comments
Closed

[PATCH] Coverity: perlfunc: recommend chdir("/') after chroot #13772

p5pRT opened this issue Apr 26, 2014 · 16 comments
Labels

Comments

@p5pRT
Copy link

p5pRT commented Apr 26, 2014

Migrated from rt.perl.org#121740 (status was 'resolved')

Searchable as RT121740$

@p5pRT
Copy link
Author

p5pRT commented Apr 26, 2014

From @jhi

It is good security practice to chdir to root after chroot (just google
for "chroot chdir"). Coverity suggested adding the chdir("/") to
pp_chroot, which is not quite what we want (the Perl "glue" is supposed
to be thin). But mention the chdir in perlfunc/chroot.

Attached.

@p5pRT
Copy link
Author

p5pRT commented Apr 26, 2014

From @jhi

0001-Inspired-by-Coverity-perl5-CID-28931.patch
From 4d9c3d74cb366055e77acee119c713de4d2e0aeb Mon Sep 17 00:00:00 2001
From: Jarkko Hietaniemi <jhi@iki.fi>
Date: Thu, 24 Apr 2014 18:16:30 -0400
Subject: [PATCH] Inspired by Coverity perl5 CID 28931: Insecure chroot:
 (CHROOT) chroot_call: Calling chroot() ... without calling chdir("/")
 immediately after.

The Perl chroot() is a thin wrapper around the system call, so the
chdir("/") should not go there.  But adding a note about the chdir()
being a good idea to perlfunc/chroot.
---
 pod/perlfunc.pod | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod
index 9a5ee74..3883a94 100644
--- a/pod/perlfunc.pod
+++ b/pod/perlfunc.pod
@@ -1012,6 +1012,9 @@ change your current working directory, which is unaffected.)  For security
 reasons, this call is restricted to the superuser.  If FILENAME is
 omitted, does a C<chroot> to C<$_>.
 
+B<NOTE:> It is good security practice to immediately after C<chroot()>
+to do C<chdir("/")> (to the root directory).
+
 Portability issues: L<perlport/chroot>.
 
 =item close FILEHANDLE
-- 
1.9.2

@p5pRT
Copy link
Author

p5pRT commented May 15, 2014

From @rjbs

fine with me for 5.20
--
rjbs

@p5pRT
Copy link
Author

p5pRT commented May 15, 2014

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented May 17, 2014

From @jkeenan

On Thu May 15 09​:48​:19 2014, rjbs wrote​:

fine with me for 5.20

rjbs​: Are we actually going to include this in 5.20?

I don't see it yet in blead (54ff0ea).

Thank you very much.
Jim Keenan

@p5pRT
Copy link
Author

p5pRT commented May 17, 2014

From @jhi

On Saturday-201405-17, 12​:14, James E Keenan via RT wrote​:

On Thu May 15 09​:48​:19 2014, rjbs wrote​:

fine with me for 5.20

rjbs​: Are we actually going to include this in 5.20?

I don't see it yet in blead (54ff0ea).

I pushed now *something* to blead... I'm still figuring out this
newfangled git thing, so please be gentle with me. What was wrong with
steam locomotives and top hats, anyway?

Thank you very much.
Jim Keenan

---
via perlbug​: queue​: perl5 status​: open
https://rt-archive.perl.org/perl5/Ticket/Display.html?id=121740

@p5pRT
Copy link
Author

p5pRT commented May 17, 2014

From @jhi

On Saturday-201405-17, 14​:40, Jarkko Hietaniemi wrote​:

I pushed now*something* to blead... I'm still figuring out this
newfangled git thing, so please be gentle with me. What was wrong with
steam locomotives and top hats, anyway?

Aaaaargh... looks like I pushed something else, too, unintentionally,
the APItest.xs changes re perl #121882, that is.

@p5pRT
Copy link
Author

p5pRT commented May 17, 2014

From @khwilliamson

On 05/17/2014 12​:40 PM, Jarkko Hietaniemi wrote​:

On Saturday-201405-17, 12​:14, James E Keenan via RT wrote​:

On Thu May 15 09​:48​:19 2014, rjbs wrote​:

fine with me for 5.20

rjbs​: Are we actually going to include this in 5.20?

I don't see it yet in blead (54ff0ea).

I pushed now *something* to blead... I'm still figuring out this
newfangled git thing, so please be gentle with me. What was wrong with
steam locomotives and top hats, anyway?

In the meantime I've been working on pushing that patch. The commit msg
heading is too long for what git likes, and there is an extra 'to' in
the text that makes it ungrammatical, also missing commas, and then I
realized that moving the clause to the end made it sound better to my
native English-speaker ears, and didn't require any commas.

@p5pRT
Copy link
Author

p5pRT commented May 17, 2014

From @jhi

On Saturday-201405-17, 14​:54, karl williamson via RT wrote​:

the text that makes it ungrammatical, also missing commas, and then I
realized that moving the clause to the end made it sound better to my
native English-speaker ears, and didn't require any commas.

Well, now you can pull blead, and exercise your native English-speaker
fingers :-)

@p5pRT
Copy link
Author

p5pRT commented May 17, 2014

From @rjbs

* Jarkko Hietaniemi <jhi@​iki.fi> [2014-05-17T14​:51​:40]

On Saturday-201405-17, 14​:40, Jarkko Hietaniemi wrote​:

I pushed now*something* to blead... I'm still figuring out this
newfangled git thing, so please be gentle with me. What was wrong with
steam locomotives and top hats, anyway?

Aaaaargh... looks like I pushed something else, too, unintentionally, the
APItest.xs changes re perl #121882, that is.

a54d950 is a complete mess. This should never have happened.

I am *really really* tempted to move blead backward, but probably we won't.

This is the time when anybody objects to me doing it, while I go back to this
conference.

--
rjbs

@p5pRT
Copy link
Author

p5pRT commented May 17, 2014

From @jhi

On Saturday-201405-17, 15​:20, Ricardo Signes via RT wrote​:

a54d950 is a complete mess. This should never have happened.

I am*really really* tempted to move blead backward, but probably we won't.

This is the time when anybody objects to me doing it, while I go back to this
conference.

Sorry about that. Please undo my mess if possible / necessary.

I think I sort of know what happened, I basically did a merge commit
when I shouldn't (for such a trivial change), and then panicked, trying
to clean up the mess, quite unsuccessfully...

@p5pRT
Copy link
Author

p5pRT commented May 17, 2014

From @bulk88

On Sat May 17 12​:20​:54 2014, perl.p5p@​rjbs.manxome.org wrote​:

a54d950 is a complete mess. This should never have happened.

I am *really really* tempted to move blead backward, but probably we
won't.

This is the time when anybody objects to me doing it, while I go back
to this
conference.

Not sure if my opinion matters, but I always support "force" git resets to fix bad git histories. In this case the lack of rebasing makes the git timeline look insane. See attached pic.

--
bulk88 ~ bulk88 at hotmail.com

@p5pRT
Copy link
Author

p5pRT commented May 17, 2014

From @bulk88

bleadmerge.PNG

@p5pRT
Copy link
Author

p5pRT commented May 17, 2014

From @jkeenan

On Sat May 17 12​:20​:54 2014, perl.p5p@​rjbs.manxome.org wrote​:

* Jarkko Hietaniemi <jhi@​iki.fi> [2014-05-17T14​:51​:40]

On Saturday-201405-17, 14​:40, Jarkko Hietaniemi wrote​:

I pushed now*something* to blead... I'm still figuring out this
newfangled git thing, so please be gentle with me. What was wrong
with
steam locomotives and top hats, anyway?

Aaaaargh... looks like I pushed something else, too, unintentionally,
the
APItest.xs changes re perl #121882, that is.

a54d950 is a complete mess. This should never have happened.

I am *really really* tempted to move blead backward, but probably we
won't.

This is the time when anybody objects to me doing it, while I go back
to this
conference.

Net changes, as shown by 'git diff 54ff0ea​:', appear reasonable.

But I guess that would complicate 'git blame' and make blead differ from RC1, correct?

Thank you very much.
Jim Keenan

@p5pRT
Copy link
Author

p5pRT commented May 20, 2014

From @tonycoz

On Sat Apr 26 12​:03​:17 2014, jhi wrote​:

It is good security practice to chdir to root after chroot (just google
for "chroot chdir"). Coverity suggested adding the chdir("/") to
pp_chroot, which is not quite what we want (the Perl "glue" is supposed
to be thin). But mention the chdir in perlfunc/chroot.

Attached.

A patch for the same purpose was applied as b00d10d, so closing this ticket.

Tony

@p5pRT
Copy link
Author

p5pRT commented May 20, 2014

@tonycoz - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant