Skip to content

Commit

Permalink
SEC: Warn about PDF encryption security
Browse files Browse the repository at this point in the history
See #1754
  • Loading branch information
MartinThoma committed Mar 28, 2023
1 parent 1563e8e commit 70e040b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions docs/user/encryption-decryption.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
## Encrypt

> ⚠️ WARNING ⚠️: pypdf only implements [RC4 encryption](https://en.wikipedia.org/wiki/RC4).
> This encryption algorithm is insecure. The more modern and secure AES
> encryption is not implemented. pypdf can only decrypt, but not encrypt with
> AES.
Add a password to a PDF (encrypt it):

```python
Expand Down
6 changes: 6 additions & 0 deletions pypdf/_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1027,6 +1027,12 @@ def encrypt(
5 and 6 control annotations, 9 for form fields,
10 for extraction of text and graphics.
"""
warnings.warn(
"pypdf only implements RC4 encryption so far. "
"The RC4 algorithm is insecure. Either use a library that supports "
"AES for encryption or put the PDF in an encrypted container, "
"for example an encrypted ZIP file."
)
if user_pwd is not None:
if user_password is not None:
raise ValueError(
Expand Down

0 comments on commit 70e040b

Please sign in to comment.