Better HN
topnewbestaskshowjobs
Log inSign up

SethMLarson

1,019 karma · joined Jun 19, 2017 (9y ago) · 170 submissions

Security Developer-in-Residence at the Python Software Foundation, PSF Fellow, Minnesoootan, he/him

https://sethmlarson.dev

Submissions

comment 2y ago · link · parent

Isolation and ephemerality can still be accomplished using virtualization while providing the benefits of self-hosted resources.

comment 2y ago · link · parent

The recommended guidance is either vendoring dependencies or pinning to hashes (pip --require-hashes, poetry.lock, pipfile). When updating your dependencies you should review the actual file getting downloaded.

Compiled binaries are harder, you might consider compiling them from source and comparing the output. This is where build reproducibility comes in to play.

There's a lot more coming in the Python packaging security space that'll make this easier and just safer in general. Stay tuned :)

comment 2y ago · link · parent

Great write-up! There's a few things you can do as either a producer or consumer to thwart this sort of attack:

Producers:

* Self-hosted infrastructure should not be running anonymous code. PRs should be reviewed before code executes on your infrastructure. Potentially should be a GitHub default when using self-hosted runners?

* Permissions for workflows and tokens should be minimal and fine-grained. "permissions: read-all" should be your default when creating a new workflow. Prevents lateral movement via modifying workflow code.

* Self-hosted infrastructure should be isolated and ephemeral, persistence was key for lateral movement with this attack.

Consumers:

* Use a lock file with pinned hashes, either --require-hashes or poetry/pipfile

* Review the diff of the file getting installed, not the GitHub source code. This will get easier when build provenance becomes a feature of PyPI.

* If your organization is large enough, consider mirroring PyPI with approved releases so the manual review effort can be amortized.

* More coming in this space for Python, like third-party attestations about malware, provenance, build reproducibility, etc. Stay tuned! :)

94.

Security Developer-in-Residence Weekly Report #24(sethmlarson.dev ↗)

2 points · by SethMLarson · 2y ago · discuss

95.

AI and Wonder(sethmlarson.dev ↗)

1 points · by SethMLarson · 2y ago · discuss

96.

Mahjong tiles and Unicode variation selectors(sethmlarson.dev ↗)

2 points · by SethMLarson · 2y ago · discuss

97.

Python listed as memory-safe language in latest CISA recommendations(sethmlarson.dev ↗)

2 points · by SethMLarson · 2y ago · 3 comments

comment 2y ago · link · parent

Python itself is memory-safe, but you're right that a good chunk of the packaging ecosystem uses memory unsafe languages for performance and interop.

The Python Software Foundation noted this in our response to the US Government RFI on open source security. There are efforts to make using Rust easier as a systems language for Python packages and some security-critical packages like 'cryptography' have migrated to Rust.

comment 2y ago · link · parent

I am looking forward to PyPI's "answer" to this class of malicious packages with automated third-party reporting (and hopefully long-term, quarantining or even deletion). Hopefully this project will swing the narrative closer to the /actual/ security threat that these packages represent to their respective package ecosystems. The PyPI Safety and Security Engineer Mike Fiedler is working on this project :)

comment 3y ago · link · parent

CPython is evaluating the options in this guide: https://github.com/python/cpython/issues/112301#issue-200494...

101.

Querying every file in every release on the Python Package Index (redux)(ibis-project.org ↗)

2 points · by SethMLarson · 3y ago · discuss

102.

Querying every file in every release on the Python Package Index(sethmlarson.dev ↗)

2 points · by SethMLarson · 3y ago · discuss

comment 3y ago · link · parent

The post is incorrect, only IPv6 addresses are meant to be put in brackets.

comment 3y ago · link · parent

This is the way.

105.

"For You" is not for me(sethmlarson.dev ↗)

3 points · by SethMLarson · 3y ago · discuss

106.

PyPI Security(talkpython.fm ↗)

50 points · by SethMLarson · 3y ago · 21 comments

comment 3y ago · link · parent

This doesn't change the Python language or packaging so wouldn't require a PEP, I'm working with release managers on this GitHub repo: https://github.com/python/release-tools

comment 3y ago · link · parent

I believe the only differences were uid/gid and username/groupname values between the two tarballs. One had the information of Thomas Wouters, the release manager of 3.12, and the other had generic GitHub Action usernames/groups.

Normalizing these values to something known like 0/0 would have done the trick.

comment 3y ago · link · parent

You've got it right, SLSA build provenance in particular only tells you that the artifact you have came from X software repo, at Y commit/tag, built using Z workflow. SLSA doesn't make any mention of what is actually in the artifact (but you can now safely verify the correct commit knowing it was used as input).

Typosquatting is an interesting one, because if you've made a typo in one place but not the other (ie installing package name "requestss", but repo is "psf/requests") then SLSA would "save" you by erroring on the mismatch. But that doesn't stop you from typoing in /both/ parameters.

comment 3y ago · link · parent

Great question! PyPI already supports Trusted Publishers [1], which gets you most of the benefits of SLSA build provenance (provable link between artifacts and a public software repository). Implementing Trusted Publishers is the recommended first step for ecosystems looking to implement build provenance [2].

[1] https://docs.pypi.org/trusted-publishers/

[2] https://github.com/ossf/wg-securing-software-https://docs.py...

I don't think there's a big effort /right now/ to implement complete SLSA build provenance for PyPI and expose it for users to verify.

comment 3y ago · link · parent

Jake has written their experience elsewhere (and is linked to many times in the article, too) for example: https://jakeseliger.com/2023/08/27/on-being-ready-to-die-and...

comment 3y ago · link · parent

Protocols with @runtime_checkable fit your description!

113.

Python and SLSA(sethmlarson.dev ↗)

1 points · by SethMLarson · 3y ago · discuss

114.

Hi-Chew Pokédex(sethmlarson.dev ↗)

1 points · by SethMLarson · 3y ago · discuss

comment 3y ago · link · parent

In v2.0 urllib3 it's:

  import urllib3
  
  urllib3.request("POST", "https://httpbin.org/post", json={"key": "value"})

comment 3y ago · link · parent

This is part of what Spotify did to determine urllib3 as an award recipient: https://engineering.atspotify.com/2022/04/announcing-the-spo...

comment 3y ago · link · parent

The name isn't straightforward, is it? :) The project name "urllib3" is an unfortunate joke on "urllib" and "urllib2" in the standard library, since it's made to supersede both of those modules in functionality.

The original author of the package likely didn't know it'd grow to be the most downloaded package at the time!

comment 3y ago · link · parent

I think it's less to do with a small number of companies making big donations like this, it'd be much nicer to have many organizations making even small contributions based on usage/complexity of the project.

This is what Tidelift is trying to do, the biggest barrier to more projects getting the amount of funding that we do from them is the number of businesses wanting that sort of relationship with their open source dependencies. The amount we receive from Tidelift is not typical for most projects since we're a medium complexity project that is a part of almost every Python project dependency list.

comment 3y ago · link · parent

Yeah the amount of financial support we receive is mostly dependent on individual organizations. For example in 2021 we didn't receive any large donations, only support from Tidelift.

120.

Urllib3 in 2022(sethmlarson.dev ↗)

197 points · by SethMLarson · 3y ago · 113 comments

123456