|  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
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
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:

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

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

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

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

Expected result:
[root@test 1]# php56 keyauth.php
[root@test 1]# php70 keyauth.php
[root@test 1]#

Actual result:
[root@test 1]# php56 keyauth.php
[root@test 1]# php70 keyauth.php
[root@test 1]#


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-11-22 20:06 UTC] chupaka at gmail dot com
 [2021-02-10 11:29 UTC]
I think this issue has already been fixed[1], but a new release is

[1] <>
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jul 20 01:01:29 2024 UTC