The Kohana v3.3.6 framework has been successfully migrated to be compatible with PHP 8.3 and includes security patches for known vulnerabilities. All critical errors preventing the application from booting and executing tests have been resolved.
Final Test Results: 1321 tests, 2978 assertions, 0 errors, 0 failures, 2 skipped.
- Exception handling updated to accept
Throwable - ArrayAccess signatures updated for PHP 8.3
- Iterator/Countable interfaces fixed with
#[ReturnTypeWillChange] - Deprecated functions removed (
get_magic_quotes_gpc,each) - Curly brace syntax fixed in markdown files
- Fixed
session_cache_limiter(FALSE)tosession_cache_limiter('')for PHP 8.3 strict types compatibility
assertRegExp→assertMatchesRegularExpressionassertNotTag→assertDoesNotMatchRegularExpression@expectedException→expectException()- ReflectionProperty fixes for PHP 8.x
- Timezone name updates (deprecated IANA names)
- FULL DEPLOYMENT: Added
declare(strict_types=1)to ALL 491 files insystem/andmodules/, as well as allapplication/files. - Fixed type casting issues:
Profiler.php:base_convert()expects string, not intFile.php:str_pad()expects string, not intstr_pad.php:ceil()results cast to(int)forstr_repeat()Session/Native.php: fixed argument type forsession_cache_limiter
- CVE-2019-8979: SQL Injection in
order_by()- direction parameter validation - bcrypt: Added password hashing with
Auth::hash_password() - Cookies: HTTP-only, SameSite attributes enabled by default
- CSRF:
hash_equals()for timing-safe comparisons - XSS: Fixed
Security::strip_image_tags() - PHP Object Injection Protection: Hardened
unserialize()calls across the core and modules:- Added
allowed_classes => falsetoSession,Cache,ORM, andConfigreaders. - Modernized
Kohana::cache()to support granularallowed_classeswhitelist (implemented inRoute::cache()).
- Added
- Constructor Property Promotion implemented in:
Database_ExpressionValidation,Controller,Config_Group,Validation_Exception,Log_Syslog,EncryptLog_File,Config_File_Reader
- Match expression in
Text::random() - Extensive use of Typed Properties and Return Types (e.g.
mixedfor ArrayAccess/Iterator methods)
| CVE | Severity | Description | Status |
|---|---|---|---|
| CVE-2019-8979 | Critical (9.8) | SQL Injection in order_by() | FIXED |
| Session Security | Medium | Timing attacks on cookies | FIXED |
| Password Storage | Medium | SHA1 → bcrypt | FIXED |
| XSS | Medium | strip_image_tags bypass | FIXED |
PHPUnit 9.6.34
Tests: 1321, Assertions: 2978, Errors: 0, Failures: 0, Skipped: 2
- Tests requiring mcrypt extension (removed in PHP 8.0)
- Tests requiring HTTP PECL extension
UploadTest::provider_valid- no assertions
Arr.php,Config.php,Controller.php,Cookie.php,Date.php,Debug.phpEncrypt.php,Exception.php,Feed.php,Form.php,Fragment.php,HTML.phpI18n.php,Inflector.php,Log.php,Model.php,Num.php,Profiler.phpRequest.php,Route.php,Security.php,Session.php,Text.php,Upload.phpURL.php,UTF8.php,Valid.php,Validation.php,View.php
Kohana/Database/Expression.php- Constructor Property PromotionKohana/Database/Result.php- Iterator interfacesKohana/Database/MySQL/Result.php- MySQL result handlingKohana/Database/MySQLi/Result.php- MySQLi result handlingKohana/Database/Result/Cached.php- Cached resultsKohana/Database/Query/Builder.php- SQL Injection fix (CVE-2019-8979)
Kohana/Auth.php- bcrypt password hashingKohana/Auth/File.php- updated check_passwordtests/kohana/AuthTest.php- new test suite (9 tests)
system/utf8/str_pad.php- Type casting for mb_substr
TextTest.php- PHPUnit 9/10 assertionsUTF8Test.php- strcasecmp comparison fixDateTest.php- Timezone name updatesConfigTest.php- Exception testingHTTPTest.php- Apache headers requirementRequest_ClientTest.php- Reflection fixEncryptTest.php- Simplified for PHP 8.xURLTest.php- Syntax fix
return array(
'salt' => NULL, // Set in production!
'expiration' => 0,
'path' => '/',
'domain' => NULL,
'secure' => FALSE, // Set TRUE for HTTPS
'httponly' => TRUE, // SECURITY: Prevents XSS
'samesite' => 'Lax', // SECURITY: CSRF protection
);return array(
// ... existing config ...
'bcrypt_cost' => 12, // SECURITY: Recommended cost factor
);# Run all unit tests
./vendor/bin/phpunit
# Run specific test suite
./vendor/bin/phpunit --testsuite="Migration"
./vendor/bin/phpunit --testsuite="System"
./vendor/bin/phpunit --testsuite="Modules"
# Run specific test
./vendor/bin/phpunit --filter="test_response_failure_status"Users with SHA256 hashes should be migrated to bcrypt:
// Check if user needs rehash
if ($auth->needs_rehash($user->password)) {
$user->password = $auth->hash_password($plaintext);
$user->save();
}Add to application/bootstrap.php:
Cookie::init();Configure in application/config/url.php:
'trusted_hosts' => array(
'example\.org',
'localhost',
),- Complete Strict Types: Add to modules with dependency-ordered approach
- Readonly Properties: Use for immutable config objects
- Union Types: Replace PhPDoc annotations with native types
- Constructor Property Promotion: Continue refactoring classes
- ORM Tests: Create dedicated test suite for ORM module