|
| 1 | +# Security Implication of the Typeshed Stub Uploader |
| 2 | + |
| 3 | +Security for the stub uploader is of the highest importance. If the stub |
| 4 | +uploader gets compromised, an attacker could upload manipulated stub |
| 5 | +packages to gain full access to developer machines or even production hosts. |
| 6 | +Considering the high trust, quick turnaround, and automated installation of |
| 7 | +stub packages, this could have significant security implications. |
| 8 | + |
| 9 | +## Maintainers |
| 10 | + |
| 11 | +Only a small number of typeshed maintainers have commit rights for this |
| 12 | +repository to minimize the attack vector in case of hacked accounts. This |
| 13 | +is also the reason that this repository is part of a separate GitHub |
| 14 | +organization and not the [python](https://github.com/python) or |
| 15 | +[psf](https://github.com/psf) organizations, like typeshed is. |
| 16 | + |
| 17 | +Typeshed maintainers without commit rights are still considered maintainers |
| 18 | +of the stub uploader and are encouraged to manage issues and send and review |
| 19 | +pull requests. |
| 20 | + |
| 21 | +## Typeshed Data |
| 22 | + |
| 23 | +To ensure that a compromised typeshed repository can't lead to compromised |
| 24 | +stub packages, all typeshed data is verified by the stub uploader before |
| 25 | +building packages. The stub uploader ensures that only stub and metadata |
| 26 | +files are added to the stub packages. This also means that no code from the |
| 27 | +typeshed repository must be executed while building packages, and no |
| 28 | +modules must be imported. |
| 29 | + |
| 30 | +## Dependencies |
| 31 | + |
| 32 | +Another possible attack vector is dependencies of stub packages. |
| 33 | +A compromised dependency can have a similar effect to when a stub package |
| 34 | +gets compromised directly. Therefore, only certain dependencies are |
| 35 | +allowed: |
| 36 | + |
| 37 | +* Dependencies on other stub packages created by typeshed. |
| 38 | +* Dependencies on packages the upstream package depends on – even recursively. |
| 39 | + Since it's likely that a stub package gets installed alongside the |
| 40 | + upstream package, this does not introduce an additional security liability. |
| 41 | +* Dependencies that are explicitly allowlisted in the stub uploader. These |
| 42 | + dependencies are vetted to be from a trusted source. |
| 43 | + |
| 44 | +## PyPI Uploads |
| 45 | + |
| 46 | +Stub packages are uploaded to PyPI by the PyPI user |
| 47 | +[typeshed_bot](https://pypi.org/user/typeshed_bot/) using an API token. |
| 48 | +The packages are owned solely by that user, so that no other PyPI user can |
| 49 | +upload new versions of the packages, in case the PyPI account of a |
| 50 | +maintainer becomes compromised. |
| 51 | + |
| 52 | +## Reporting a Vulnerability |
| 53 | + |
| 54 | +To report an issue, go to https://github.com/typeshed-internal/stub_uploader/security. We commit to respond to any issue within 14 days and promptly fix any problems. |
0 commit comments