Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix use with Sequoia Chameleon #17

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open

Conversation

DemiMarie
Copy link

@DemiMarie DemiMarie commented Sep 30, 2024

See individual commit messages for details.

Fixes: QubesOS/qubes-issues#9483
Fixes: QubesOS/qubes-issues#9527
Fixes: QubesOS/qubes-issues#9528
Fixes: QubesOS/qubes-issues#9529

@marmarek
Copy link
Member

CI fails in several jobs.

And also, please add reference to python/cpython#79174 to the description of the commit vendoring in that class.

@DemiMarie
Copy link
Author

CI fails in several jobs.

I’ll sort this out

And also, please add reference to python/cpython#79174 to the description of the commit vendoring in that class.

It’s actually worse: we need to vendor the entire stream infrastructure, because the StreamReader and StreamWriter constructors are not part of the public API. The only supported options are:

  1. Use the low-level asyncio API.
  2. Use blocking I/O, perhaps wrapping it in an async interface.
  3. Use a third-party library that does (1) or (2).
  4. Use a socket-based service (but this breaks backwards compatibility).

@marmarek
Copy link
Member

It’s actually worse: we need to vendor the entire stream infrastructure, because the StreamReader and StreamWriter constructors are not part of the public API

Documentation says "It is not recommended to instantiate StreamReader objects directly", which is not the same as unsupported.
Anyway, the constructor signature changed last time 5 years ago. Even if not officially supported, I think it's safe to assume it wont break (or very rarely at least).

@DemiMarie DemiMarie changed the title Multiple bug fixes Fix signing with Sequoia Chameleon Oct 22, 2024
GnuPG uses fingerprints for these keys that are 64 hex bytes, not 40
like for the other algorithms.  Fix the tests to account for this.
Debian does not support these algorithms.
This command is used by Sequoia Chameleon.

Fixes: QubesOS/qubes-issues#9483.
This option makes no sense in the context of split-gpg2 and fails if the
gpg-agent-connection is restricted, causing Sequoia Chameleon to
disconnect.  Return a fake 'OK' response instead of passing the command
to the agent.

Fixes: QubesOS/qubes-issues#9527
@DemiMarie DemiMarie changed the title Fix signing with Sequoia Chameleon Fix use with Sequoia Chameleon Oct 22, 2024
Copy link

codecov bot commented Oct 22, 2024

Codecov Report

Attention: Patch coverage is 85.54217% with 12 lines in your changes missing coverage. Please review.

Project coverage is 81.28%. Comparing base (ba13c18) to head (a87f5a0).

Files with missing lines Patch % Lines
splitgpg2/__init__.py 85.36% 12 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #17      +/-   ##
==========================================
+ Coverage   80.86%   81.28%   +0.42%     
==========================================
  Files           2        2              
  Lines        1348     1373      +25     
==========================================
+ Hits         1090     1116      +26     
+ Misses        258      257       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Since 58efb86 ("Return fake 'OK' to setting 'display' option") it
has no users.
pinentry-mode=ask is the default, so this is a no-op.  Return OK instead
of an error code.  Sequoia Chameleon sends pinentry-mode=ask and
disconnects when it gets an error.

Fixes: QubesOS/qubes-issues#9528
Currently, this command is blocked.  GnuPG detects that the agent
connection is restricted and doesn't try to use it, while Sequoia
Chameleon does not implement the fallback and is unable to list secret
keys or decrypt messages.  Furthermore, gpg prints
"gpg: problem with fast path key listing: Forbidden - ignored", which
Mutt interprets as a prompt the user must respond to.  This causes the
user to need to press enter twice to send a signed email.

Fix these problems by allowing this request.  The request does not work
over a restricted connection, so an unrestricted connection must be
used.  However, the filtering done by split-gpg2 is far stronger than
the access checks in gpg-agent so there is no loss of security.

Fixes: QubesOS/qubes-issues#9529
This bug is old, but it only triggers if there are no UIDs, which is why
testing didn't reveal it.  I suspect old versions of mypy just did not
catch the bug.
- Compile all regular expressions during initialization.
- Check for newline injection before sending data to the agent.
- Misc cleanups.
No functional change intended.
This saves some code.
These commands are forbidden over a restricted connection to the agent,
but GnuPG wars if they are not present and Sequoia Chameleon requires
them.  Fortunately, they are trivial to sanitize input for, so there is
zero risk of an injection vulnerability.  Therefore, use a separate
unrestricted agent connection for these commands.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants