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

src: ensure that file descriptors 0-2 are valid #875

Merged
merged 2 commits into from
Feb 18, 2015

Conversation

bnoordhuis
Copy link
Member

Check that stdin, stdout and stderr map to open file descriptors and
remap them to /dev/null if that isn't the case. Protects against
information leaks or worse when io.js is started with closed stdio
file descriptors.

R=@vkurchatkin

The second commit is an unrelated typo fix.

@cjihrig
Copy link
Contributor

cjihrig commented Feb 18, 2015

LGTM

@vkurchatkin
Copy link
Contributor

This looks good to me, though it definitely doesn't fix #831

@bnoordhuis
Copy link
Member Author

Agreed, but it does fix something in that it makes io.js a little more robust and secure. BTW, CI: https://jenkins-iojs.nodesource.com/view/iojs/job/iojs+any-pr+multi/178/

PR-URL: nodejs#875
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Vladimir Kurchatkin <[email protected]>
Check that stdin, stdout and stderr map to open file descriptors and
remap them to /dev/null if that isn't the case.  Protects against
information leaks or worse when io.js is started with closed stdio
file descriptors.

PR-URL: nodejs#875
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Vladimir Kurchatkin <[email protected]>
@bnoordhuis bnoordhuis closed this Feb 18, 2015
@bnoordhuis bnoordhuis deleted the check-stdio-fds branch February 18, 2015 17:13
@bnoordhuis bnoordhuis merged commit b5f25a9 into nodejs:v1.x Feb 18, 2015
@rvagg rvagg mentioned this pull request Feb 20, 2015
addaleax pushed a commit that referenced this pull request Mar 20, 2017
Check that stdin, stdout and stderr are valid file descriptors on
Windows. If not, reopen them with 'nul' file.

Refs: #875
Fixes: #11656
PR-URL: #11863
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Jeremiah Senkpiel <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
jungx098 pushed a commit to jungx098/node that referenced this pull request Mar 21, 2017
Check that stdin, stdout and stderr are valid file descriptors on
Windows. If not, reopen them with 'nul' file.

Refs: nodejs#875
Fixes: nodejs#11656
PR-URL: nodejs#11863
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Jeremiah Senkpiel <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
MylesBorins pushed a commit that referenced this pull request Mar 28, 2017
Check that stdin, stdout and stderr are valid file descriptors on
Windows. If not, reopen them with 'nul' file.

Refs: #875
Fixes: #11656
PR-URL: #11863
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Jeremiah Senkpiel <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
MylesBorins pushed a commit that referenced this pull request Apr 18, 2017
Check that stdin, stdout and stderr are valid file descriptors on
Windows. If not, reopen them with 'nul' file.

Refs: #875
Fixes: #11656
PR-URL: #11863
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Jeremiah Senkpiel <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
MylesBorins pushed a commit that referenced this pull request Apr 18, 2017
Check that stdin, stdout and stderr are valid file descriptors on
Windows. If not, reopen them with 'nul' file.

Refs: #875
Fixes: #11656
PR-URL: #11863
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Jeremiah Senkpiel <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
MylesBorins pushed a commit that referenced this pull request Apr 19, 2017
Check that stdin, stdout and stderr are valid file descriptors on
Windows. If not, reopen them with 'nul' file.

Refs: #875
Fixes: #11656
PR-URL: #11863
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Jeremiah Senkpiel <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
MylesBorins pushed a commit that referenced this pull request Apr 19, 2017
Check that stdin, stdout and stderr are valid file descriptors on
Windows. If not, reopen them with 'nul' file.

Refs: #875
Fixes: #11656
PR-URL: #11863
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Jeremiah Senkpiel <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
andrew749 pushed a commit to michielbaird/node that referenced this pull request Jul 19, 2017
Check that stdin, stdout and stderr are valid file descriptors on
Windows. If not, reopen them with 'nul' file.

Refs: nodejs/node#875
Fixes: nodejs/node#11656
PR-URL: nodejs/node#11863
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Jeremiah Senkpiel <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
obiwac added a commit to obiwac/node that referenced this pull request Aug 30, 2022
When checking for the validity of the stdio file descriptors (nodejs#875),
ones which don't exist are intended to be remapped to /dev/null (and, if
that doesn't work, we abort).

This however doesn't work on all platforms and in all cases (e.g. /dev/null
could already have been opened by the acting process and not actually be
mapped to the expected file descriptor); instead, use the `dup2` syscall
as a more robust solution (conforms to POSIX.1).
obiwac added a commit to obiwac/node that referenced this pull request Aug 30, 2022
When checking for the validity of the stdio file descriptors (nodejs#875),
ones which don't exist are intended to be remapped to /dev/null (and, if
that doesn't work, we abort).

This however doesn't work on all platforms and in all cases (e.g.
/dev/null could already have been opened by the acting process and not
actually be mapped to the expected file descriptor); instead, use the
`dup2` syscall as a more robust solution (conforms to POSIX.1).

Refs: nodejs#875
Fixes: nodejs/help#2411
obiwac added a commit to obiwac/node that referenced this pull request Aug 30, 2022
When checking for the validity of the stdio file descriptors (nodejs#875),
ones which don't exist are intended to be remapped to /dev/null (and, if
that doesn't work, we abort).

This however doesn't work on all platforms and in all cases (e.g.
/dev/null could already have been opened by the acting process and not
actually be mapped to the expected file descriptor); instead, use the
`dup2` syscall as a more robust solution (conforms to POSIX.1).
obiwac added a commit to obiwac/node that referenced this pull request Aug 30, 2022
When checking for the validity of the stdio file descriptors
(nodejs#875), ones which don't exist are intended to be remapped to
/dev/null (and, if that doesn't work, we abort).

This however doesn't work on all platforms and in all cases (e.g.
/dev/null could already have been opened by the acting process and not
actually be mapped to the expected file descriptor); instead, use the
`dup2` syscall as a more robust solution (conforms to POSIX.1).
obiwac added a commit to obiwac/node that referenced this pull request Aug 30, 2022
When checking for the validity of the stdio file descriptors
(nodejs#875), ones which don't exist are intended to be remapped to
/dev/null (and, if that doesn't work, we abort).

This however doesn't work on all platforms and in all cases (e.g.
/dev/null could already have been opened by the acting process and not
actually be mapped to the expected file descriptor); instead, use the
`dup2` syscall as a more robust solution (conforms to POSIX.1).

Fixes: nodejs/help#2411
Refs: nodejs#875
obiwac added a commit to obiwac/node that referenced this pull request Aug 31, 2022
When checking for the validity of the stdio file descriptors
(nodejs#875), ones which don't exist are intended to be remapped to
/dev/null (and, if that doesn't work, we abort).

This however doesn't work on all platforms and in all cases (e.g.
/dev/null could already have been opened by the acting process and not
actually be mapped to the expected file descriptor); instead, use the
`dup2` syscall as a more robust solution (conforms to POSIX.1).

Fixes: nodejs/help#2411
Refs: nodejs#875
obiwac added a commit to obiwac/node that referenced this pull request Aug 31, 2022
When checking for the validity of the stdio file descriptors
(nodejs#875), ones which don't exist are intended to be remapped to
/dev/null (and, if that doesn't work, we abort).

This however doesn't work on all platforms and in all cases (e.g.
/dev/null could already have been opened by the acting process and not
actually be mapped to the expected file descriptor); instead, use the
`dup2` syscall as a more robust solution (conforms to POSIX.1).

Fixes: nodejs/help#2411
Refs: nodejs#875
obiwac added a commit to obiwac/node that referenced this pull request Aug 31, 2022
When checking for the validity of the stdio file descriptors
(nodejs#875), ones which don't exist are intended to be remapped to
/dev/null (and, if that doesn't work, we abort).

This however doesn't work on all platforms and in all cases (e.g.
/dev/null could already have been opened by the acting process and not
actually be mapped to the expected file descriptor); instead, use the
`dup2` syscall as a more robust solution (conforms to POSIX.1).

Fixes: nodejs/help#2411
Refs: nodejs#875
obiwac added a commit to obiwac/node that referenced this pull request Aug 31, 2022
When checking for the validity of the stdio file descriptors
(nodejs#875), ones which don't exist are intended to be remapped to
/dev/null (and, if that doesn't work, we abort).

This however doesn't work on all platforms and in all cases (e.g.
/dev/null could already have been opened by the acting process and not
actually be mapped to the expected file descriptor); instead, use the
`dup2` syscall as a more robust solution (conforms to POSIX.1).

Fixes: nodejs/help#2411
Refs: nodejs#875
obiwac added a commit to obiwac/node that referenced this pull request Sep 1, 2022
When checking for the validity of the stdio file descriptors
(nodejs#875), ones which don't exist are intended to be remapped to
/dev/null (and, if that doesn't work, we abort).

This however doesn't work on all platforms and in all cases (e.g.
/dev/null could already have been opened by the acting process and not
actually be mapped to the expected file descriptor); instead, use the
`dup2` syscall as a more robust solution (conforms to POSIX.1).

Fixes: nodejs/help#2411
Refs: nodejs#875
obiwac added a commit to obiwac/node that referenced this pull request Sep 1, 2022
When checking for the validity of the stdio file descriptors
(nodejs#875), ones which don't exist are intended to be remapped to
/dev/null (and, if that doesn't work, we abort).

This however doesn't work on all platforms and in all cases, and is not
anymore required by POSIX; instead, use the `dup2` syscall as a more
robust solution (conforms to POSIX.1).

Fixes: nodejs/help#2411
Refs: nodejs#875
nodejs-github-bot pushed a commit that referenced this pull request Oct 26, 2022
When checking for the validity of the stdio file descriptors
(#875), ones which don't exist are intended to be remapped to
/dev/null (and, if that doesn't work, we abort).

This however doesn't work on all platforms and in all cases, and is not
anymore required by POSIX; instead, use the `dup2` syscall as a more
robust solution (conforms to POSIX.1).

Fixes: nodejs/help#2411
Refs: #875
PR-URL: #44461
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
RafaelGSS pushed a commit that referenced this pull request Nov 1, 2022
When checking for the validity of the stdio file descriptors
(#875), ones which don't exist are intended to be remapped to
/dev/null (and, if that doesn't work, we abort).

This however doesn't work on all platforms and in all cases, and is not
anymore required by POSIX; instead, use the `dup2` syscall as a more
robust solution (conforms to POSIX.1).

Fixes: nodejs/help#2411
Refs: #875
PR-URL: #44461
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
RafaelGSS pushed a commit that referenced this pull request Nov 10, 2022
When checking for the validity of the stdio file descriptors
(#875), ones which don't exist are intended to be remapped to
/dev/null (and, if that doesn't work, we abort).

This however doesn't work on all platforms and in all cases, and is not
anymore required by POSIX; instead, use the `dup2` syscall as a more
robust solution (conforms to POSIX.1).

Fixes: nodejs/help#2411
Refs: #875
PR-URL: #44461
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
danielleadams pushed a commit that referenced this pull request Dec 30, 2022
When checking for the validity of the stdio file descriptors
(#875), ones which don't exist are intended to be remapped to
/dev/null (and, if that doesn't work, we abort).

This however doesn't work on all platforms and in all cases, and is not
anymore required by POSIX; instead, use the `dup2` syscall as a more
robust solution (conforms to POSIX.1).

Fixes: nodejs/help#2411
Refs: #875
PR-URL: #44461
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
danielleadams pushed a commit that referenced this pull request Dec 30, 2022
When checking for the validity of the stdio file descriptors
(#875), ones which don't exist are intended to be remapped to
/dev/null (and, if that doesn't work, we abort).

This however doesn't work on all platforms and in all cases, and is not
anymore required by POSIX; instead, use the `dup2` syscall as a more
robust solution (conforms to POSIX.1).

Fixes: nodejs/help#2411
Refs: #875
PR-URL: #44461
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
danielleadams pushed a commit that referenced this pull request Jan 3, 2023
When checking for the validity of the stdio file descriptors
(#875), ones which don't exist are intended to be remapped to
/dev/null (and, if that doesn't work, we abort).

This however doesn't work on all platforms and in all cases, and is not
anymore required by POSIX; instead, use the `dup2` syscall as a more
robust solution (conforms to POSIX.1).

Fixes: nodejs/help#2411
Refs: #875
PR-URL: #44461
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants