Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Commit 516a6f8

Browse files
committed
[ZF2014-05] Fix for null-byte binding
- Disables ability to provide a null byte in a password when binding.
1 parent d516863 commit 516a6f8

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

library/Zend/Ldap.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,10 @@ public function bind($username = null, $password = null)
814814
{
815815
$moreCreds = true;
816816

817+
// Security check: remove null bytes in password
818+
// @see https://net.educause.edu/ir/library/pdf/csd4875.pdf
819+
$password = str_replace("\0", '', $password);
820+
817821
if ($username === null) {
818822
$username = $this->_getUsername();
819823
$password = $this->_getPassword();

tests/Zend/Ldap/BindTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,4 +260,14 @@ public function testResourceIsAlwaysReturned()
260260
$this->assertTrue(is_resource($ldap->getResource()));
261261
$this->assertEquals(TESTS_ZEND_LDAP_USERNAME, $ldap->getBoundUser());
262262
}
263+
264+
/**
265+
* @see https://net.educause.edu/ir/library/pdf/csd4875.pdf
266+
*/
267+
public function testBindWithNullPassword()
268+
{
269+
$ldap = new Zend_Ldap($this->_options);
270+
$this->setExpectedException('Zend_Ldap_Exception', 'Invalid credentials');
271+
$ldap->bind($this->_altUsername, "\0invalidpassword");
272+
}
263273
}

0 commit comments

Comments
 (0)