TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: Pragmatic way to avoid supply chain attacks as a developer

27 点作者 RoboTeddy9 个月前
In the usual course of writing software, it&#x27;s common to install huge dependency chains (npm, pypi), and any vulnerable package could spell doom. There&#x27;s some nasty stuff out there, like https:&#x2F;&#x2F;pytorch.org&#x2F;blog&#x2F;compromised-nightly-dependency&#x2F; which uploaded people&#x27;s SSH keys to the attacker.<p>It&#x27;s easy to say just &quot;use containers&quot; or &quot;use VMs&quot; — but are there pragmatic workflows for doing these things that don&#x27;t suffer from too many performance problems or general pain&#x2F;inconvenience?<p>Are containers the way to go, or VMs? Which virtualization software? Is it best to use one isolated environment per project no matter how small, or for convenience&#x27;s sake have a grab-bag VM that contains many projects all of which are low value?<p>Theorycrafting is welcome, but am particularly interested in hearing from anyone who has made this work well in practice.

12 条评论

comprev9 个月前
A large portion of my role at $DayJob is around improving supply chain security.<p>Some examples of how we do it:<p>- Devs can only use hardened (by us) Docker images hosted inside our infrastructure. Policies enforce this during CI and runtime on clusters.<p>- All Maven&#x2F;PIP&#x2F;NodeJS&#x2F;etc. dependencies are pulled through via proxy and scanned before first use. All future CI jobs pull from this internal cache.<p>- Only a handful of CI runners have outbound connectivity to the public internet (via firewalls). These runners have specific tags for jobs needing connectivity. All other runners pull dependencies &#x2F; push artefacts from within our network.<p>- The CI Runners with Internet connectivity have domains whitelisted at the firewall level, and so far very few requests have been made to add new domains.<p>- External assets, e.g an OpenJDK artefact, have their checksums validated during the build stage of our base images. This checksum is included in Docker image metadata should we wish to download the asset again and compare against the public one.
评论 #41289327 未加载
评论 #41289335 未加载
评论 #41289471 未加载
legobeet9 个月前
A defense-in-depth approach with a special eye to compartmentalization&#x2F;separation&#x2F;sandboxing coupled with principle-of-least privilege is a good stance to take, I think. Also keep in mind that &quot;security is a process, not a product&quot;. There is no silver bullet no tool will save you from yourself...<p>With this in mind:<p>- <a href="https:&#x2F;&#x2F;qubes-os.org" rel="nofollow">https:&#x2F;&#x2F;qubes-os.org</a> - Use separate VMs for separate domains. Use disposable VMs for temporary sessions.<p>- <a href="https:&#x2F;&#x2F;github.com&#x2F;legobeat&#x2F;l7-devenv">https:&#x2F;&#x2F;github.com&#x2F;legobeat&#x2F;l7-devenv</a> - My project. Separate containers for IDE and (ephemeral) code-under-test. Transparent access to just the directories needed and nothing else, without compromising on performance and productivity. Separation of authentication token while transparent to your scripts and dev-tools. Editor add-ons are pinned via submodules and baked into the image at build-time (and easy to update on a rebuild). Feedback very welcome!<p>- In general, immutable distros like Fedora Silverblue and MicroOS (whatever happened to SUSE ALP?) also worth considering, to limit persistence. Couples well with a setup like the one I linked above.<p>- Since you seem to be in a Node.js context, I should also mention @lavamoat&#x2F;allow-scripts (also affiliated via $work) as something you can consider to reel in your devDeps: <a href="https:&#x2F;&#x2F;github.com&#x2F;LavaMoat&#x2F;LavaMoat&#x2F;tree&#x2F;main&#x2F;packages&#x2F;allow-scripts&#x2F;">https:&#x2F;&#x2F;github.com&#x2F;LavaMoat&#x2F;LavaMoat&#x2F;tree&#x2F;main&#x2F;packages&#x2F;allo...</a>
mikewarot9 个月前
The root cause of many of our woes is <i>ambient authority</i>. This is the metaphorical equivalent of building an electrical grid without fuses or circuit breakers.<p>You have to trust everything, and any breach of trust breaks it all. This approach is insane, and yet, widely accepted as the way things were always done, and will always be done.<p>If you ever get the chance to use capability based security, otherwise known as the principle of least privilege, or multilevel security, do so.<p>Know that permission flags in Android, or the UAC crap in Windows, or AppArmor are NOT capability based security.
swiftcoder9 个月前
There are really only a handful of approaches to preventing this kind of supply chain attack, and all come with tradeoffs (ranging from the infeasible to the merely impractical):<p>- Don&#x27;t take any 3rd party dependencies. Build everything in house instead. Likely only possible in niche areas of government&#x2F;defence where sky-high budgets intersect with intense scrutiny.<p>- Manually validate each new version of every dependency in your tree. Also very expensive, complex vulnerabilities will likely still slip through (i.e. things like SPECTRE aren&#x27;t going to be caught in code review).<p>- Use firewalls&#x2F;network security groups&#x2F;VPC-equivalents to prevent any network traffic that isn&#x27;t specifically related to the correct operation of your software. Increasingly hard to enforce, as our tech stacks rely on more and more SaaS offerings. Needs a properly staffed network admin to enforce and reduce the pain points on developers.<p>- Network isolated VMs&#x2F;containers that can only talk to a dedicated container that handles all network traffic. Imposes odd constraints on software architecture, doesn&#x27;t play well with SaaS dependencies.<p>In practice you run with whatever combination of the above you can afford, and hope for the best.
blueflow9 个月前
Be conservative in your software choices. If your software stack relies on a few off-the-shelf Debian packages and nothing more, you are pretty safe.
keepamovin9 个月前
I see the people posting here suggesting isolation for development. While this is a good model, doesn&#x27;t it suffer from the risk that you are not using the same isolation set up in production, for whatever reason?<p>In that sense, isolation for develop to solve supply chain security seems a symptom-treater not a cause-treater.<p>A more extreme approach is to:<p>minimize dependencies, built a lot in-house, don&#x27;t update pre-vetted dependencies before another audit<p>In general, I think a big dependency chain is useful for getting to PoC quickly (and in some cases it&#x27;s indeed unavoidable, eg. numpy etc), but in building many simplish web apps and client server applications it&#x27;s feasible to have a very narrow dependency chain, especially back-end. You can even do this front-end if you eschew framework stuff.
meiraleal9 个月前
What I started to do is to remove external packages and bringing just the parts I need to the codebase, usually using chatgpt to write a smaller version of the lib. no dependencies, no supply chain attack. Also stopped using npm.
rekado9 个月前
This may be of interest: <a href="https:&#x2F;&#x2F;programming-journal.org&#x2F;2023&#x2F;7&#x2F;1&#x2F;" rel="nofollow">https:&#x2F;&#x2F;programming-journal.org&#x2F;2023&#x2F;7&#x2F;1&#x2F;</a> &quot;Building a Secure Software Supply Chain with GNU Guix&quot;
bravetraveler9 个月前
I&#x27;ve found an effective band-aid is <i>&#x27;become the supply chain&#x27;</i>. Running your own cache, poorly, has advantages. You don&#x27;t get the latest silliness by forgetting to update sometimes.
评论 #41289361 未加载
mindcrash9 个月前
Implement SLSA on developer&#x2F;org&#x2F;infra level<p><a href="https:&#x2F;&#x2F;slsa.dev&#x2F;spec&#x2F;v1.0&#x2F;" rel="nofollow">https:&#x2F;&#x2F;slsa.dev&#x2F;spec&#x2F;v1.0&#x2F;</a>
评论 #41284065 未加载
h4ck_th3_pl4n3t9 个月前
CycloneDX tools offer packages for each and every programming language. [1]<p>The dependency track project accumulates all dependency vulnerabilities in a dashboard. [2]<p>Container SBOMs can be generated with syft and grype [3] [4]<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;CycloneDX">https:&#x2F;&#x2F;github.com&#x2F;CycloneDX</a><p>[2] <a href="https:&#x2F;&#x2F;github.com&#x2F;DependencyTrack">https:&#x2F;&#x2F;github.com&#x2F;DependencyTrack</a><p>[3] <a href="https:&#x2F;&#x2F;github.com&#x2F;anchore&#x2F;syft">https:&#x2F;&#x2F;github.com&#x2F;anchore&#x2F;syft</a><p>[4] <a href="https:&#x2F;&#x2F;github.com&#x2F;anchore&#x2F;grype">https:&#x2F;&#x2F;github.com&#x2F;anchore&#x2F;grype</a>
评论 #41289132 未加载
ralala9 个月前
For protecting your developer machine, devcontainers will provide at least some isolation.