php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73578 ssh2_auth_pubkey_file destroys its parameters if they contain ~/
Submitted: 2016-11-22 01:14 UTC Modified: 2021-02-10 11:29 UTC
Votes:8
Avg. Score:4.0 ± 0.9
Reproduced:7 of 7 (100.0%)
Same Version:4 (57.1%)
Same OS:6 (85.7%)
From: chupaka at gmail dot com Assigned:
Status: Open Package: ssh2 (PECL)
PHP Version: Irrelevant OS: Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2016-11-22 01:14 UTC] chupaka at gmail dot com
Description:
------------
When calling ssh2_auth_pubkey_file with $pubkeyfile or $privkeyfile starting with ~/, it destroys contents of strings (and php70 sometimes Segfaults).

Looks like it's connected with "Explode '~/paths' stopgap fix because libssh2 does not accept tilde for homedir" block in ssh2.c

Test script:
---------------
<?php

$pub = '~/.ssh/id_rsa.pub';
$priv = '~/.ssh/id_rsa';

echo "$pub\n$priv\n";

$ssh = ssh2_connect("server.com");
ssh2_auth_pubkey_file($ssh, 'root', $pub, $priv);

echo "$pub\n$priv\n";


Expected result:
----------------
[root@test 1]# php56 keyauth.php
~/.ssh/id_rsa.pub
~/.ssh/id_rsa
~/.ssh/id_rsa.pub
~/.ssh/id_rsa
[root@test 1]# php70 keyauth.php
~/.ssh/id_rsa.pub
~/.ssh/id_rsa
~/.ssh/id_rsa.pub
~/.ssh/id_rsa
[root@test 1]#


Actual result:
--------------
[root@test 1]# php56 keyauth.php
~/.ssh/id_rsa.pub
~/.ssh/id_rsa
 d_rsa.pub
▒9▒<d_rsa
[root@test 1]# php70 keyauth.php
~/.ssh/id_rsa.pub
~/.ssh/id_rsa
▒▒;▒>▒▒U▒
▒'▒d_rsa
[root@test 1]#


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-11-22 20:06 UTC] chupaka at gmail dot com
https://bugs.php.net/bug.php?id=63725
 [2021-02-10 11:29 UTC] cmb@php.net
I think this issue has already been fixed[1], but a new release is
pending.

[1] <https://github.com/php/pecl-networking-ssh2/commit/bfc0d963cc45d10a1161740bd36fb7a9a1b64aa6>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 13:01:28 2024 UTC