mirror of
https://github.com/go-gitea/gitea.git
synced 2026-05-11 01:07:59 -05:00
GPG Signature never verifies if signing is done on Windows #14542
Open
opened 2025-11-02 11:15:43 -06:00 by GiteaMirror
·
14 comments
No Branch/Tag Specified
main
release/v1.25
release/v1.24
release/v1.23
release/v1.22
release/v1.21
release/v1.20
release/v1.19
release/v1.18
release/v1.17
release/v1.16
release/v1.15
release/v1.14
release/v1.13
release/v1.12
release/v1.11
release/v1.10
release/v1.9
release/v1.8
v1.25.3
v1.25.2
v1.25.1
v1.25.0
v1.24.7
v1.25.0-rc0
v1.26.0-dev
v1.24.6
v1.24.5
v1.24.4
v1.24.3
v1.24.2
v1.24.1
v1.24.0
v1.23.8
v1.24.0-rc0
v1.25.0-dev
v1.23.7
v1.23.6
v1.23.5
v1.23.4
v1.23.3
v1.23.2
v1.23.1
v1.23.0
v1.23.0-rc0
v1.24.0-dev
v1.22.6
v1.22.5
v1.22.4
v1.22.3
v1.22.2
v1.22.1
v1.22.0
v1.23.0-dev
v1.22.0-rc1
v1.21.11
v1.22.0-rc0
v1.21.10
v1.21.9
v1.21.8
v1.21.7
v1.21.6
v1.21.5
v1.21.4
v1.21.3
v1.21.2
v1.20.6
v1.21.1
v1.21.0
v1.21.0-rc2
v1.21.0-rc1
v1.20.5
v1.22.0-dev
v1.21.0-rc0
v1.20.4
v1.20.3
v1.20.2
v1.20.1
v1.20.0
v1.19.4
v1.21.0-dev
v1.20.0-rc2
v1.20.0-rc1
v1.20.0-rc0
v1.19.3
v1.19.2
v1.19.1
v1.19.0
v1.19.0-rc1
v1.20.0-dev
v1.19.0-rc0
v1.18.5
v1.18.4
v1.18.3
v1.18.2
v1.18.1
v1.18.0
v1.17.4
v1.18.0-rc1
v1.19.0-dev
v1.18.0-rc0
v1.17.3
v1.17.2
v1.17.1
v1.17.0
v1.17.0-rc2
v1.16.9
v1.17.0-rc1
v1.18.0-dev
v1.16.8
v1.16.7
v1.16.6
v1.16.5
v1.16.4
v1.16.3
v1.16.2
v1.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.0-rc1
v1.3.2
v1.3.1
v1.3.0
v1.3.0-rc2
v1.3.0-rc1
v1.2.3
v1.2.2
v1.2.1
v1.2.0
v1.2.0-rc3
v1.2.0-rc2
v1.1.4
v1.2.0-rc1
v1.1.3
v1.1.2
v1.1.1
v1.1.0
v1.0.2
v1.0.1
v1.0.0
v0.9.99
Labels
Clear labels
$20
$250
$50
$500
backport/done
💎 Bounty
docs-update-needed
good first issue
hacktoberfest
issue/bounty
issue/confirmed
issue/critical
issue/duplicate
issue/needs-feedback
issue/not-a-bug
issue/regression
issue/stale
issue/workaround
lgtm/need 2
modifies/api
modifies/translation
outdated/backport/v1.18
outdated/theme/markdown
outdated/theme/timetracker
performance/bigrepo
performance/cpu
performance/memory
performance/speed
pr/breaking
proposal/accepted
proposal/rejected
pr/wip
pull-request
reviewed/wontfix
💰 Rewarded
skip-changelog
status/blocked
topic/accessibility
topic/api
topic/authentication
topic/build
topic/code-linting
topic/commit-signing
topic/content-rendering
topic/deployment
topic/distribution
topic/federation
topic/gitea-actions
topic/issues
topic/lfs
topic/mobile
topic/moderation
topic/packages
topic/pr
topic/projects
topic/repo
topic/repo-migration
topic/security
topic/theme
topic/ui
topic/ui-interaction
topic/ux
topic/webhooks
topic/wiki
type/bug
type/deprecation
type/docs
type/enhancement
type/feature
type/miscellaneous
type/proposal
type/question
type/refactoring
type/summary
type/testing
type/upstream
Mirrored from GitHub Pull Request
No Label
type/bug
Milestone
No items
No Milestone
Projects
Clear projects
No project
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/gitea#14542
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ieris19 on GitHub (Jun 3, 2025).
Description
I have attempted several times to set up Git commit signing in both Linux and Windows. Linux is always a breeze, generate a key, setup git, commit with signature, passphrase and off-you-go. With Windows, it's always MASSIVE pain in the ass every time, and its never worked.
Never knew why either, until now. I have recently realized that my GPG signatures are different for the same content depending on the OS, which is a problem, because I believe that is the reason my git signatures work fine on Linux, but never on Windows, is because the servers are running Linux and are probably expecting the signature to be the same as the one it generates in Linux.
I am currently running Windows 11 and openSUSE Tumbleweed within WSL, but I have also verified with my Gitea server running Fedora. For the first two I am running gpg 2.5.6 with libgcrypt 1.11.1, Fedora is a bit behind at gpg 2.4.7 with libgcrypt 1.11.0-unknown as reported by the command:
I have followed GitHub's guide on how to generate a GPG key, using my Windows machine. Afterwards, I followed Red Hat's guide to migrate these keys onto other machines, in order to have the exact same key in every computer.
Uploading the key to Gitea promptly asks for confirmation, which is where the issue arises. Gitea offers a token and asks for a signature.
Pasting this command into Windows, generates a signature that Gitea refuses with the following message:
This has all been done on Windows so far, when I paste the command into either Linux environment that I imported the keys to, both times, the verification is simply accepted.
Unsurprisingly, committing from Windows doesn't verify the commits either
Gitea Version
1.23.7
Can you reproduce the bug on the Gitea demo site?
Yes
Git Version
git version 2.49.0
Operating System
Fedora Linux 42 (Workstation Edition)
How are you running Gitea?
I am running Gitea on bare metal from the executable provided at https://dl.gitea.com/gitea/
To be precise, https://dl.gitea.com/gitea/1.23.7/gitea-1.23.7-linux-amd64
I can also replicate the issue on https://demo.gitea.com
Database
SQLite
@levicki commented on GitHub (Jun 15, 2025):
The problem is that the suggested signing command which works for Linux:
Results in
<token>\nbeing sent togpgfor signing.As you might have guessed,
echocommand under Windows not only keeps the quotes, but also replaces\nwith\r\nresulting in the string"<token>\r\n"which doesn't match what Gitea expects to be signed.Aggravating the problem is the short token validity time which makes it hard if not impossible to manually prepare the correct token string.
Proper fix would be not quoting the token in the command example, and not including OS-specific line ending in the verification string to begin with.
@ieris19 commented on GitHub (Jun 16, 2025):
Do you think then this issue runs deeper into Git for Windows as well? Even signing the commits through git directly never really worked on Gitea or Github for me, but that could also just be an issue with my setup. I have never managed to get git commit signing setup on Windows but it's always been dead simple on Linux.
My Windows machine is broken right now, so I can't quite test this, but I should have it back next week to further research the situation.
@levicki commented on GitHub (Jun 16, 2025):
No, I have a working setup. I only discovered this problem as I had to reimport the keys since I lost the old ones to reinstall.
If you want to sign by default, install gpg4win (you only need Kleopatra checked from optional) and in your
.gitconfigput:Tag bit is optional (I don't want signed tags since they require message).
@GiteaBot commented on GitHub (Jul 17, 2025):
We close issues that need feedback from the author if there were no new comments for a month. 🍵
@levicki commented on GitHub (Jul 17, 2025):
@lunny Why is this still tagged as
needs-feedbackwhen all feedback necessary to reproduce and fix the reported issue was provided by me?@ieris19 commented on GitHub (Jul 17, 2025):
Unfortunately, my Windows machine is still out of commission (the wonders of RMA repairs), but I believe something should still be done about this, at the very least as you @levicki said:
I can probably locate the relevant code and submit a pull request if it would be welcome, but I would need to get my Windows machine back before I can test it and submit a better cross-platform example command
@levicki commented on GitHub (Jul 18, 2025):
That one is going to be a challenge on Windows. I was looking for a way and didn't find anything reliable, not to mention that some commands even output Unicode (UCS-2).
Ideal solution for users would be if Gitea had a small helper executable that registers as a protocol handler (for example
gitea:) so when you click a link which looks likegitea://sign-challenge?key_id=fedbca&token=123abcbrowser launches the protocol handler with key id and challenge token as parameters which in turn talks togpg-agentand prompts user to sign it using that key_id and then posts the signature back to your local Gitea instance for validation.I do not have a slightest idea how to write cross-platform protocol handler though, and I somehow doubt the fine people who work on Gitea would expend the time to do this just to fix an occasional annoyance for a handful of Windows users they might have.
EDIT:
There's perhaps an easier option — writing a browser extension which uses Native Messaging to talk to
gpg-agent.It is cross-platform, user is already in the browser, and it would require minimal change on the Gitea server end to work.
@levicki commented on GitHub (Jul 18, 2025):
Another option would be a signing helper console app, here's a minimal working code example in .Net 8.0 (note that not all possible error conditions are handled!):
It has minimal dependencies and it should work on all platforms where .Net Core is supported. Here's example request:
And a response:
Gitea can directly issue challenge to it on
http://localhost:5000and the user will get prompted to enter password for theirkey_idbygpg-agent. Hope this helps.@ieris19 commented on GitHub (Jul 18, 2025):
Potentially, it could be as simple as providing a small tabulated example (Unix-like/Windows) with an OS appropriate command in each. Then on the server, have Gitea verify against
<token>\nor<token>\r\nbased on the tab selected?I think this one adds less complexity over requiring the user to download any sort of helper (whether that is a small server, an extension or anything else for that matter).
Gitea could potentially also just check against
<token>\nand if failed, check against<token>\r\n, it wouldn't be that costly.Gitea could also just choose which one to do first based on the User Agent, just like it could select the tab automatically opened based on it (user would always be free to switch tabs if the user agent is wrong)
@levicki commented on GitHub (Jul 18, 2025):
As I said, Windows to my knowledge can't output with
\n, only with\r\nand even things that can (like PowerShell commands) outputs UCS-2 (16-bit Unicode).Silently including whitespace in a nonce and expecting user to handle that is bad design in my book.
And where does that kind of edge-casing stop? If user pastes Unicode do they also check if every other byte is
\0and silently convert Unicode to ANSI in that case? And what if it's Big Endian? Do they also check for that? And what if that Unicode string has invalid code points which convert to?? Should they strip those out?I am not saying they couldn't do that, but as a principal software engineer myself I think they shouldn't.
I also don't see a point of validating the gpg key in this way — if you input invalid gpg key, then your commits won't validate and show as properly signed. Not even GitHub is bothering with such checks because there's nothing you can gain by entering the wrong public gpg key into your own account.
@ieris19 commented on GitHub (Jul 21, 2025):
In my personal experience, this is very useful, it makes it so that I can genuinely test my GPG key without having to go make a commit and sign it somewhere. I think it's valuable, and regressing such a feature is probably pointless.
Unicode, Big Endian, and other edge cases should also probably be covered, but I understand that means software complexity and development time and that might not be desirable. But supporting the OS with the biggest market share is the bare minimum in my opinion. I run Linux on my main computer, and I appreciate open source as is, but I need Windows for my school work as well as work.
I think this should either be up to the user to handle or just silently checked against the two major line endings that are used by every operating system I know of. Like I said, a first assumption can be made based on UA and if that check fails, an alternative check can be performed against the other line ending. That and removing the quotes from the example should make this pretty much universal.
@levicki commented on GitHub (Jul 21, 2025):
Sorry, but the bolded part makes no sense. You seem to misunderstand the purpose of that check.
Commits are signed locally when you run
git commit. You can verify withgit log -1 --show-signature— no push needed.Unless you paste the wrong GPG key into Gitea, your commit will verify fine after push.
If you want to test your GPG key, sign any file with
gpg --signand verify it — no commit required.Gitea’s check only proves you own the matching private key. Other systems (GitHub, Azure) don’t bother, because it’s pointless — the worst that happens is your commit shows unsigned, and you fix it by pasting the correct public key and by running
git commit --amendandgit push --force.TL;DR — IMO, the only check Gitea should perform when managing GPG, SSH keys, or other sensitive security settings is re-prompting your password. Allowing adding emails, setting them as primary without confirmation, and adding SSH and/or GPG keys all without password prompts opens doors for misuse if someone gains access to your logged-in session.
@TechnickPoogi commented on GitHub (Jul 31, 2025):
Описание решения:
Шаги для решения проблемы:
Откройте Git Bash
Выполните команду:
Модифицируйте команду подписи, добавив
-nпослеecho, чтобы получилось:Аккуратно скопируйте вывод (без переносов строк, без \r\n, должен остаться только \n после echo) и вставьте его в Gitea.
Подпись будет успешно подтверждена.
Solution steps:
Steps to resolve the issue:
Open Git Bash
Run the following command:
Modify the signing command by adding
-nafterecho, so it becomes:Carefully copy the output (ensure no line breaks, only \n after echo, not \r\n) and paste it into Gitea.
The signature should now verify successfully.
Also, in SSH key verify, developers used option "-n" in echo and even provided commands for cmd and powershell. If I have time, I will try to issue a PR for similar functionality for GPG
@levicki commented on GitHub (Jul 31, 2025):
@TechnickPoogi You misunderstood the problem — problem is that Gitea expects
\nto be in the token.