从 `oapi-codegen` 在 GitHub 安全开源基金中的经验教训
Lessons learned from `oapi-codegen`'s time in the GitHub Secure Open Source Fund

原始链接: https://www.jvt.me/posts/2026/02/17/oapi-codegen-github-secure/

## oapi-codegen 与 GitHub 安全开源基金 oapi-codegen 项目(根据 OpenAPI 规范生成 Go 代码)参与了 GitHub 安全开源基金,以加强其安全实践并扩大维护者团队。该项目认识到其关键地位——处理 API 交互中的敏感数据——旨在确保生成的代码值得信赖并防止漏洞。 该资金(1万美元)提供了专门的时间来解决安全漏洞,此前由于单人维护者的工作量而面临挑战。这包括改进 GitHub 权限以控制发布,努力遵循 OpenSSF 最佳实践,以及探索威胁建模、模糊测试和漏洞处理。 该项目通过研讨会和问答环节促进了学习,并提供了一个宝贵的同伴群体来分享经验。有趣的是,合并贡献的暂时放缓实际上*提高了*安全性,降低了引入潜在有害代码的风险。 最终,该基金使 oapi-codegen 能够自信地招募新的维护者,并继续为开发者提供安全且维护良好的工具。预计将公开分享进一步的学习和改进。

黑客新闻 新的 | 过去的 | 评论 | 提问 | 展示 | 招聘 | 提交 登录 从 `oapi-codegen` 在 GitHub 安全开源基金中的经验教训 (jvt.me) 3 分,作者 zdw 1 小时前 | 隐藏 | 过去的 | 收藏 | 讨论 帮助 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请 YC | 联系 搜索:
相关文章

原文

As noted in GitHub's post, oapi-codegen was one of the projects taking part in the third GitHub Secure Open Source Fund session.

I'd like to take a moment to reflect on the program, and some learnings I've taken from it.

One of the quotes I shared at the end of the program summed up my time:

Having time dedicated to following best practices has been invaluable☆(well, $10k)

Why did we join the fund?

oapi-codegen is a project that takes an OpenAPI specification and generates Go code for either interacting with that API via an autogenerated client, or generates scaffolding for a number of HTTP servers and web frameworks to reduce the implementation burden, as well as generating types for API request/responses.

Given the project is in a fairly privileged position - interacting with every HTTP request/response on either client or server-side, and likely exposed to sensitive data and credentials - securing the project is very important.

As a code generator, oapi-codegen can generate a fair bit of code for you to commit to your project.

But does everyone review the generated code? Hopefully yes 🫣 But given we can't guarantee it, we want to make sure that nothing dodgy could land in folks' codebases.

Extending the maintainer pool

On top of this, for the last ~2 years, I've been effectively maintaining oapi-codegen on my own. As I've written about a couple of times, maintaining a large project like this is fairly time consuming and difficult, especially if it's only you.

Additionally, oapi-codegen isn't a single project, and other child projects, such as middleware for request/response validation, or conversions between types at runtime, also need maintenance.

The project is sufficiently complex, led by user examples, and has a lot of usage that can make it hard to maintain for $0/month.

Over the last few years I've been very appreciative of a few companies sponsoring the work, but the project requires more hours of work, especially given the many large companies using it, but giving nothing back.

While looking at options for increasing the number of folks who maintain the project, a key area I wanted to focus on was to make sure that the security of the project would not be compromised.

This was, in fact, the key reason I submitted oapi-codegen to the program - I wanted support in making sure that I'd done my due diligence to make sure we were setting the project and its users up for success as we introduced new members to maintain the project.

For instance, adding a new collaborator with Write access onto the repository would, by default, allow the pushing of a Git tag, which would then be a released Go version that automated tools like Renovate would happily start upgrading folks to.

Alternatively, the new collaborator able to approve a PR and merge it onto the main branch would also be treated as a version that's ready to be used, as we recommend pinning to commits off main to get changes before a release.

I love that Go provides a straightforward process for users to get updates, but making sure there was a level of control and protection for our users was important, as I've worked hard to build confidence with our users.

Having dedicated time (and money) to fund the work to focus on security was a very big mentally, as it meant I didn't feel "guilty" for not looking at PRs or Issues raised by users, and instead focussing on security as a dedicated pool of time.

With this in place, we are much more able to take on additional collaborators and maintainers.

Understanding our gaps

Over the years, I've worked in and around supply chain security, and on efforts to ensure the enterprise I worked for has had good security posture.

I would say I have a fairly good understanding of good GitHub permissions models, areas to focus to make sure that bad actors can't leverage lax permissions, and experience with some of the tools to help audit usage.

But the reality of only having one human maintaining the project was at odds with this - enforcing code review of all PRs worked for external contributor PRs, but when I needed to make changes, I didn't have a second reviewer.

Since 2024, I've been working towards the OpenSSF Best Practices "passing" grade badge for oapi-codegen, and working towards following best practices there.

As with many parts of the industry, there's often multitudes contained in a single area, and security is absolutely not the exception to the rule. Naturally there were gaps we had in other areas that we knew we were lacking in, and areas that we didn't know we were lacking in.

During the program, we got a chance to dig into different areas with a mix of talks, workshops and Q&A sessions, looking at areas like threat modelling, fuzzing and how to handle a security advisory (which may then become a CVE).

Having the time to work on the program meant that we could address some of the security gaps, not limited to:

As well as these concrete steps, we have also made less outwardly visible steps, like work towards a threat model for the project.

It's also been nice to have a place to chat, complain and brainstorm with other maintainers who are in a very similar position.

Within the group, there was a good spread of projects' security levels, and everyone was at different points along the spectrum - more secure in some ways, but with gaps in other areas, leaving everyone feeling fairly equal overall.

Although there is the GitHub maintainers community, which I've used in the past to field questions from other maintainers, it's quite a large group, and especially when talking about slightly more sensitive things like security, it's been nice to have a small trusted group.

Can an inactive project be more secure?

This is a slightly tongue-in-cheek comment, but I thought it'd be worth noting that given oapi-codegen has recently received slightly less maintenance it could be argued that we're more secure for it 🤓

With reduced merging of community contributions (while still keeping an eye on security updates) it's meant that we're at least not merging potentially risky code changes.

That's not where we want to be, however, as we want to be both secure and well maintained!

Great teachers

The team at GitHub were great in taking us through the program in a mix of different formats - synchronous and asynchronous Q&A, workshops, presentations - and were all greatly knowledgeable and there was so much to learn.

Working to upskill folks at a range of experience levels and security understanding is a tough job, but they made it seem like it was straightforward!

Thanks again everyone 💜

Looking forward

Now we're able to talk about our time in the program publicly, expect to see some more learnings shared!

If you're interested in hearing about anything in particular, let me know!

联系我们 contact @ memedata.com