Skip to content

Commit 86ce3b0

Browse files
committed
upgrade protobuf to 6.33.5 (fix security problem)
Cause: protobuf affected by a JSON recursion depth bypass: A denial-of-service (DoS) vulnerability exists in google.protobuf.json_format.ParseDict() in Python, where the max_recursion_depth limit can be bypassed when parsing nested google.protobuf.Any messages. Due to missing recursion depth accounting inside the internal Any-handling logic, an attacker can supply deeply nested Any structures that bypass the intended recursion limit, eventually exhausting Python’s recursion stack and causing a RecursionError.
1 parent a4fecc6 commit 86ce3b0

File tree

9 files changed

+432
-412
lines changed

9 files changed

+432
-412
lines changed

Pipfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ name = "pypi"
55

66
[packages]
77
colorama = "0.4.6"
8-
opencv-contrib-python = "*"
8+
opencv-contrib-python = "4.13.0.90"
99
numpy = "2.4.1"
1010
# for macOS: opencv-contrib-python = "<=4.7.0"
1111
pillow = "*"
1212
pyzbar = "*"
13-
protobuf = "*"
13+
protobuf = "6.33.5"
1414
qrcode = "*"
1515
qreader = "1.3.2"
1616

Pipfile.lock

Lines changed: 135 additions & 134 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
[![Stand With Ukraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/badges/StandWithUkraine.svg)](https://stand-with-ukraine.pp.ua)
1515
<!-- ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/protobuf)
1616
[![GitHub Pipenv locked Python version](https://img.shields.io/github/pipenv/locked/python-version/scito/extract_otp_secrets)](https://github.com/scito/extract_otp_secrets/blob/master/Pipfile.lock)
17-
![protobuf 33.4version](https://img.shields.io/badge/protobuf-6.33.433.1-informational)-->
17+
![protobuf 33.5version](https://img.shields.io/badge/protobuf-6.33.533.1-informational)-->
1818

1919
<!-- [![Github all releases](https://img.shields.io/github/downloads/scito/extract_otp_secrets/total.svg)](https://GitHub.com/scito/extract_otp_secrets/releases/) -->
2020

@@ -385,7 +385,7 @@ python extract_otp_secrets.py = < example_export.png</pre>
385385
* Provides a debug mode (-d) for analyzing import problems
386386
* Written in modern Python using type hints and following best practices
387387
* All these features are backed by tests ran nightly
388-
* All functionality in one Python script: src/extract_otp_secrets.py (except protobuf 33.4generated code in protobuf_generated_python)
388+
* All functionality in one Python script: src/extract_otp_secrets.py (except protobuf 33.5generated code in protobuf_generated_python)
389389

390390
## KeePass
391391

@@ -748,11 +748,11 @@ sudo dnf install python3-pip perl envsubst
748748
The export QR code of "Google Authenticator" contains the URL `otpauth-migration://offline?data=…`.
749749
The data parameter is a base64 encoded proto3 message (Google Protocol Buffers).
750750

751-
Command for regeneration of Python code from proto3 message definition file (only necessary in case of changes of the proto3 message definition or new protobuf 33.4versions):
751+
Command for regeneration of Python code from proto3 message definition file (only necessary in case of changes of the proto3 message definition or new protobuf 33.5versions):
752752

753-
protoc 33.4--plugin=protoc-33.4gen-mypy=path/to/protoc-33.4gen-mypy --python_out=src/protobuf_generated_python --mypy_out=src/protobuf_generated_python src/google_auth.proto
753+
protoc 33.5--plugin=protoc-33.5gen-mypy=path/to/protoc-33.5gen-mypy --python_out=src/protobuf_generated_python --mypy_out=src/protobuf_generated_python src/google_auth.proto
754754

755-
The generated protobuf 33.4Python code was generated by protoc 33.433.1 (https://github.com/protocolbuffers/protobuf/releases/tag/v33.433.1).
755+
The generated protobuf 33.5Python code was generated by protoc 33.533.1 (https://github.com/protocolbuffers/protobuf/releases/tag/v33.533.1).
756756

757757
For Python type hint generation the [mypy-protobuf](https://github.com/nipunn1313/mypy-protobuf) package is used.
758758

build.sh

Lines changed: 67 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ run_uv=true
9797
run_gui=false
9898
generate_result_files=false
9999
PYTHONHASHSEED=31
100+
verbose=false
101+
VERBOSE=''
100102

101103
while test $# -gt 0; do
102104
case $1 in
@@ -110,16 +112,17 @@ while test $# -gt 0; do
110112
echo "-C Ignore version check of protobuf/protoc"
111113
echo "-e Build exe"
112114
echo "-n Build nuitka exe"
113-
echo "-L Do not run protoc and base build locally incl. exes"
114115
echo "-d Build docker"
115116
echo "-a Build arm"
116117
echo "-X Do not build x86_64"
117118
echo "-B Do not build base"
118119
echo "-V Do not run pipenv"
119120
echo "-U Do not run uv"
121+
echo "-L Do not run protoc and base build locally incl. exes (implies -B -V -U)"
120122
echo "-g Start extract_otp_secrets.py in GUI mode"
121123
echo "-c Clean everything"
122124
echo "-r Generate result files"
125+
echo "-v Verbose"
123126
echo "-h, --help Show help and quit"
124127
quit
125128
;;
@@ -176,6 +179,11 @@ while test $# -gt 0; do
176179
generate_result_files=true
177180
shift
178181
;;
182+
-v)
183+
verbose=true
184+
VERBOSE="-v"
185+
shift
186+
;;
179187
-c)
180188
clean=true
181189
clean_flag="--clean"
@@ -196,6 +204,7 @@ FLAKE8="$PYTHON -m flake8"
196204
MYPY="$PYTHON -m mypy"
197205
DOCKER="${DOCKER:=docker}"
198206
PYTHON_VERSION=$($PYTHON --version 2>&1 | cut -d " " -f2 | cut -d "." -f1-2)
207+
UVENV='.uvenv'
199208

200209
if $LINUX; then
201210
PWD=pwd
@@ -210,6 +219,10 @@ fi
210219
DEST="protoc"
211220

212221
if $clean; then
222+
cmd="deactivate || true"
223+
if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi
224+
eval "$cmd"
225+
213226
cmd="$DOCKER image prune -f || echo 'No docker image pruned'"
214227
if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi
215228
eval "$cmd"
@@ -256,25 +269,29 @@ if $clean; then
256269
fi
257270

258271
if $build_local; then
259-
cmd="rm -rf .venv || true"
272+
cmd="deactivate || true"
273+
if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi
274+
eval "$cmd"
275+
276+
cmd="rm -rf .venv $UVENV || true"
260277
if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi
261278
eval "$cmd"
262279

263280
cmd="$PIP install -U -r requirements-dev.txt"
264281
if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi
265282
eval "$cmd"
266283

267-
echo -e "\n\nChecking Protoc version..."
268-
cmd="VERSION=$(curl -sL https://github.com/protocolbuffers/protobuf/releases/latest | grep -E '<title>' | perl -pe's%.*Protocol Buffers v(\d+\.\d+(\.\d+)?).*%\1%')"
269-
if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi
270-
eval "$cmd"
271-
echo
284+
if ! $ignore_version_check; then
285+
echo -e "\n\nChecking Protoc version..."
286+
cmd="VERSION=$(curl -sL https://github.com/protocolbuffers/protobuf/releases/latest | grep -E '<title>' | perl -pe's%.*Protocol Buffers v(\d+\.\d+(\.\d+)?).*%\1%')"
287+
if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi
288+
eval "$cmd"
289+
echo
272290

273-
OLDVERSION=$(cat $BIN/$DEST/.VERSION.txt || echo "")
274-
echo -e "\nProtoc remote version $VERSION\n"
275-
echo -e "Protoc local version: $OLDVERSION\n"
291+
OLDVERSION=$(cat $BIN/$DEST/.VERSION.txt || echo "")
292+
echo -e "\nProtoc remote version $VERSION\n"
293+
echo -e "Protoc local version: $OLDVERSION\n"
276294

277-
if ! $ignore_version_check; then
278295
if [ "$OLDVERSION" != "$VERSION" ]; then
279296
echo "Upgrade protoc from $OLDVERSION to $VERSION"
280297

@@ -478,7 +495,7 @@ if $build_local; then
478495
# uv
479496

480497
if $run_uv; then
481-
cmd="rm -rf .venv || true"
498+
cmd="rm -rf $UVENV || true"
482499
if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi
483500
eval "$cmd"
484501

@@ -488,50 +505,73 @@ if $build_local; then
488505

489506
$UV --version
490507

491-
# cmd="$UV venv --clear"
492-
cmd="$UV venv --python $PYTHON_VERSION --clear"
508+
cmd="rm uv.lock || echo 'No uv.lock to remove'"
509+
if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi
510+
eval "$cmd"
511+
512+
cmd="$UV venv $UVENV $VERBOSE --python $PYTHON_VERSION --clear"
493513
if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi
494514
eval "$cmd"
495515

496-
$UV run python --version
516+
cmd="source $UVENV/bin/activate"
517+
if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi
518+
eval "$cmd"
519+
520+
cmd="$UV pip install $VERBOSE -U -r requirements.txt --exclude excludes.txt"
521+
if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi
522+
eval "$cmd"
497523

498-
# cmd="$UV pip install -U -r requirements.txt"
499-
# if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi
500-
# eval "$cmd"
524+
cmd="$UV pip install $VERBOSE -U -r requirements-dev.txt"
525+
if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi
526+
eval "$cmd"
501527

502-
cmd="$UV pip install -U -r requirements-dev.txt"
528+
cmd="$UV pip install $VERBOSE -U -e . --exclude excludes.txt"
503529
if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi
504530
eval "$cmd"
505531

506-
# pip -e install
532+
cmd="$UV lock --refresh $VERBOSE"
533+
if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi
534+
eval "$cmd"
507535

508-
cmd="$UV run pip install -U -e ."
536+
cmd="$UV sync --active $VERBOSE"
509537
if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi
510538
eval "$cmd"
511539

512-
cmd="$UV run pytest tests/"
540+
cmd="$UV pip uninstall $VERBOSE opencv-python"
513541
if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi
514542
eval "$cmd"
515543

516-
cmd="$UV run extract_otp_secrets example_export.txt"
544+
cmd="$UV run --active python --version"
517545
if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi
518546
eval "$cmd"
519547

520-
cmd="$UV run extract_otp_secrets - < example_export.txt"
548+
cmd="$UV run $VERBOSE --active pytest tests/"
549+
if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi
550+
eval "$cmd"
551+
552+
cmd="$UV run $VERBOSE --active extract_otp_secrets example_export.txt"
553+
if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi
554+
eval "$cmd"
555+
556+
cmd="$UV run $VERBOSE --active extract_otp_secrets - < example_export.txt"
521557
if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi
522558
eval "$cmd"
523559

524560
# Test (needs module)
525561

526-
cmd="$UV run python src/extract_otp_secrets.py example_export.txt"
562+
cmd="$UV run --active python src/extract_otp_secrets.py example_export.txt"
563+
if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi
564+
eval "$cmd"
565+
566+
cmd="$UV run --active python src/extract_otp_secrets.py example_export.txt"
527567
if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi
528568
eval "$cmd"
529569

530-
cmd="$UV run python src/extract_otp_secrets.py example_export.txt"
570+
cmd="$UV run --active python src/extract_otp_secrets.py - < example_export.txt"
531571
if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi
532572
eval "$cmd"
533573

534-
cmd="$UV run python src/extract_otp_secrets.py - < example_export.txt"
574+
cmd="deactivate"
535575
if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi
536576
eval "$cmd"
537577
fi

excludes.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
opencv-python

pyproject.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ classifiers = [
4040
]
4141
dependencies = [
4242
"colorama>=0.4.6",
43-
"opencv-contrib-python",
43+
"opencv-contrib-python>=4.13.0",
4444
"numpy>=2.0,<2.1 ; python_version >= '3.9' and python_version < '3.10'",
4545
"numpy>=2.2,<2.3 ; python_version >= '3.10' and python_version < '3.11'",
46-
"numpy>=2.4,<3.0 ; python_version >= '3.11'",
46+
"numpy>=2.4.1,<3.0 ; python_version >= '3.11'",
4747
"Pillow",
48-
"protobuf",
48+
"protobuf>=6.33.5",
4949
"pyzbar",
5050
"qrcode",
5151
"qreader<2.0.0",
@@ -73,5 +73,7 @@ enabled = true
7373

7474
# https://blog.ionelmc.ro/2014/05/25/python-packaging/#the-structure%3E
7575
# https://docs.pytest.org/en/7.1.x/explanation/goodpractices.html#which-import-mode
76+
7677
[tool.pytest.ini_options]
7778
addopts = [ "--import-mode=importlib", ]
79+
testpaths = [ "tests", ]

requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
colorama>=0.4.6
2-
opencv-contrib-python>=4.11.0
2+
opencv-contrib-python>=4.13.0
33
numpy>=2.0,<2.1 ; python_version >= "3.9" and python_version < "3.10"
44
numpy>=2.2,<2.3 ; python_version >= "3.10" and python_version < "3.11"
5-
numpy>=2.4,<3.0 ; python_version >= "3.11"
5+
numpy>=2.4.1,<3.0 ; python_version >= "3.11"
66
Pillow
7-
protobuf
7+
protobuf>=6.33.5
88
pyzbar
99
qrcode
1010
qreader<2.0.0

src/protobuf_generated_python/google_auth_pb2.py

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)