Repository navigation
Conversation
Explicação da mudança (para quem vai revisar)O problemaO rtpproxy grava o áudio de uma chamada em arquivos cujo nome é formado pelo Call-ID e pela from-tag da sessão: O caractere
O mantenedor recomenda, a longo prazo, que o cliente (OpenSIPS, Kamailio…) escolha o nome do arquivo com o comando O que este PR fazAdiciona a opção de linha de comando
Por que codificar também o Onde mexe (7 arquivos)
O que vale a pena conferir na revisão
Como testar localmenteUsando a receita de CI do próprio projeto, a partir desta branch: docker build -f docker/Dockerfile.ci --build-arg BASE_IMAGE=ubuntu:24.04 --build-arg COMPILER=gcc -t rtpproxy-ci:pr .
docker run -d --name rtpp --init --sysctl net.ipv4.ip_unprivileged_port_start=1024 --workdir /opt/rtpproxy/basic rtpproxy-ci:pr
docker exec rtpp sh -c 'groupadd --system rtpproxy; useradd --system --gid rtpproxy --no-create-home rtpproxy; chown -R rtpproxy .; \
SUB_TESTS="badpath badpath_enc" TEST_WITNESS_ENABLE=yes make -C tests check-TESTS TESTS=recording/basic'Resultado esperado: |
Resultados dos testes locaisLocal test results, reproduced with the project's own CI recipe (
The failures that also show up on master ( Resumo em português: os subtestes de gravação |
Since 9c50b4e, rtpp_record_ctor() refuses to record (R, Rs, -a) when the Call-ID or from-tag used in the file name contains '/', which keeps recordings inside of the recording directory. '/' is a legal Call-ID character and some carriers use it routinely, so those calls end up not recorded at all for clients that still rely on R. Add an opt-in --record_fname_encode option. When it is given, '/' and '%' in the Call-ID and from-tag are percent-encoded as "%2F" and "%25" before the name is built, so the file is created inside of the recording directory, never contains '/', and the original value can be recovered by decoding the "%XX" sequences. The encoded value is bounded by the same PATH_MAX buffers and the snprintf() truncation checks are kept, so names that do not fit are still refused. The default behaviour is unchanged: without the option '/' is refused as before (the log message now points at the option). Names given explicitly with C are not affected. Add a recording/basic sub-test, badpath_enc, that records the traversal Call-IDs from badpath and a Call-ID with '%' under their encoded names with the option, and still refuses an over-long Call-ID.
9f47584 to
aa1b39e
Compare
|
Aberto oficialmente: sippy#187 |
Follow-up to sippy#179.
Since 9c50b4e,
rtpp_record_ctor()refuses to record (R,Rs,-a) when the Call-ID or from-tag used in the file name contains/. That closes the path traversal, and I agree thatCwith a name chosen by the client is the right long-term answer.In the meantime, clients that still send
Rlose those recordings completely./is legal in a Call-ID and some carriers use it routinely. Moving the client toCis not always possible soon, because it needs a config change in the proxy and in everything that later finds the recording by name.This PR adds an opt-in
--record_fname_encodeoption:/is still refused exactly as in Refuse '/' in Call-ID and bound recording paths in rtpp_record_ctor sippy/rtpproxy#179, and the existingbadpathsub-test passes unmodified. The only change on that path is that the log message now mentions the option./and%in the Call-ID and from-tag are percent-encoded as%2Fand%25before the name is built:/;%as well keeps the mapping reversible, soa/banda%2Fbcannot end up in the same file. That matters because the file is opened withO_TRUNC;%XX.PATH_MAXbuffers and thesnprintf()truncation checks from Refuse '/' in Call-ID and bound recording paths in rtpp_record_ctor sippy/rtpproxy#179 stay, so names that do not fit are still refused.C/Csare not affected. Explicit names are left alone, as in Refuse '/' in Call-ID and bound recording paths in rtpp_record_ctor sippy/rtpproxy#179.Tests: a new
recording/basicsub-test,badpath_enc. With the option it records the same traversal Call-IDs asbadpath, plus one with%, and checks they are created under their encoded names inside the recording directory and nowhere else. It also checks that an over-long Call-ID is still refused. Against master the new sub-test fails, because the option does not exist there (unrecognized option '--record_fname_encode'), whilebadpathpasses on both. Local results with the project's owndocker/Dockerfile.ci+scripts/do-test.share in the comment below.Docs:
usage(),doc/manpage.xmlandrtpproxy.8.If you would rather not have a global option for this, I am happy to rework it, for example as an
R/Rscommand modifier.Resultados dos testes locais (vão como comentário no PR oficial)
Local test results, reproduced with the project's own CI recipe (
docker/Dockerfile.ci,BASE_IMAGE=ubuntu:24.04, thenscripts/do-test.sh), on this branch rebased on0c507007:0c507007(gcc)recording/basic·badpathrecording/basic·badpath_enc(new)unrecognized option '--record_fname_encode'recording/basic·files,singlefile,singlefile_c,stopall,remote,remote_precording/basic·files_stophalf,singlefile_stophalffiles_stophalfFAILEDsrc/rtpp_record.c/src/main.cThe failures that also show up on master (
*_stophalf,acct_rtcp_hep/basic,startstop/badargs,forwarding/forwarding1,playback/playback1,dtls_gw/*) come from my local Docker environment. They are identical with and without the patch. I'll rely on the GitHub CI run of this PR for those.