openssl_csr_new(): string_mask from one config applies to later calls
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 46/100
Direção de pesquisa
Start by tracing openssl_csr_new() and how it parses the config option, then inspect the OpenSSL string mask API used in that path. Reproduce the three-call sequence from the issue on PHP 8.7-dev and check existing OpenSSL CSR tests for a suitable place to cover it. Done means a config with string_mask no longer changes the result of a later call without that option, including across FPM requests.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Description
string_mask in a CSR config sets the mask process-wide, with ASN1_STRING_set_default_mask_asc(). Nothing restores it. So a later openssl_csr_new() whose config has no string_mask uses the old one. With FPM it also carries over to the next requests of the worker.
<?php
$dir = sys_get_temp_dir();
file_put_contents("$dir/set.cnf", "[ req ]\ndistinguished_name = dn\nstring_mask = nombstr\n[ dn ]\n");
file_put_contents("$dir/plain.cnf", "[ req ]\ndistinguished_name = dn\n[ dn ]\n");
function csr(string $config, string $cn): bool {
$opts = ['config' => $config];
$key = openssl_pkey_new(['private_key_type' => OPENSSL_KEYTYPE_EC, 'curve_name' => 'prime256v1'] + $opts);
return @openssl_csr_new(['commonName' => $cn], $key, $opts) !== false;
}
var_dump(csr("$dir/plain.cnf", 'Łódź'));
var_dump(csr("$dir/set.cnf", 'example'));
var_dump(csr("$dir/plain.cnf", 'Łódź'));
Resulted in this output:
bool(true)
bool(true)
bool(false)
But I expected this output instead:
bool(true)
bool(true)
bool(true)
The last call fails because nombstr doesn't allow the UTF8String the common name needs.
I'm opening a PR that saves the mask before the config is parsed and restores it after the call. oid_section and oid_file are similar: OBJ_create() adds to the global OID table and nothing removes the entries. I'm not sure that one needs fixing.
PHP Version
PHP 8.7.0-dev (master). The same code is in 8.3, 8.4, 8.5 and 8.6.
Operating System
Ubuntu 26.04, OpenSSL 3.5.5
- Linguagem predominante
- C
- Estrelas
- 41.8k
- Forks
- 8.6k
- Merge médio
- 2d 15h
- PRs com merge (30d)
- 125
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de php/php-src
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
Mantenedores costumam responder em até 1 dia
-
ext/openssl: 8.2.31+/8.3.31+ fail to build against OpenSSL 1.0.2 (ASN1_STRING_get0_data in xp_ssl.c)AbertaExtension: openssl Status: Needs Triage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 79/100
php/php-src#25402 · 2 comentários ·
Mantenedores costumam responder em até 1 dia
-
Bug Status: Needs Triage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
php/php-src#25397 · 3 comentários ·
Mantenedores costumam responder em até 1 dia
-
SNMP accepts malformed remote portsTalvez já em andamento @somethingwithproof assumiu há 21 dias. Aberta
Dificuldade 2/5 Meio dia Facilidade para iniciantes 62/100
php/php-src#25137 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Bug Status: Needs Triage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 64/100
Mantenedores costumam responder em até 1 dia
Todas as issues de php/php-src
Issues semelhantes
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
Mantenedores costumam responder em até 1 dia
-
ZIP/ZIPS decode dereferences NULL when the cached libdeflate decompressor can't be allocated (3.5 regression)Talvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 74/100
AcademySoftwareFoundation/openexr#2884 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
python-pillow/Pillow#10590 ·
Mantenedores costumam responder em até 1 dia
-
status: needs-triage type: bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
openwrt/packages#31407 · 1 comentário ·
Mantenedores costumam responder em até 1 dia