LmCast :: Stay tuned in

mitmproxy adds --emudhra option

Recorded: Oct. 22, 2026, 1:01 a.m.

Original Summarized

Add `--emudhra` option (#8500) · mitmproxy/mitmproxy@1692344 · GitHub

Skip to content

Navigation MenuSign inAppearance settingsPlatformAI CODE CREATIONGitHub CopilotWrite better code with AIGitHub Copilot appDirect agents from issue to mergeMCP RegistryIntegrate external toolsDEVELOPER WORKFLOWSActionsAutomate any workflowCodespacesInstant dev environmentsIssuesPlan and track workCode ReviewManage code changesCode QualityEnforce quality at mergeAPPLICATION SECURITYGitHub Advanced SecurityFind and fix vulnerabilitiesCode securitySecure your code as you buildSecret protectionStop leaks before they startEXPLOREWhy GitHubDocumentationBlogChangelogMarketplaceView all featuresSolutionsBY COMPANY SIZEEnterprisesSmall and medium teamsStartupsNonprofitsBY USE CASEApp ModernizationDevSecOpsDevOpsCI/CDView all use casesBY INDUSTRYHealthcareFinancial servicesManufacturingGovernmentView all industriesView all solutionsResourcesEXPLORE BY TOPICAISoftware DevelopmentDevOpsSecurityView all topicsEXPLORE BY TYPECustomer storiesEvents & webinarsEbooks & reportsBusiness insightsGitHub SkillsSUPPORT & SERVICESDocumentationCustomer supportCommunity forumTrust centerPartnersView all resourcesOpen SourceCOMMUNITYGitHub SponsorsFund open source developersPROGRAMSSecurity LabMaintainer CommunityGitHub StarsArchive ProgramREPOSITORIESTopicsTrendingCollectionsEnterpriseENTERPRISE SOLUTIONSEnterprise platformAI-powered developer platformAVAILABLE ADD-ONSGitHub Advanced SecurityEnterprise-grade security featuresCopilot for BusinessEnterprise-grade AI featuresPremium SupportEnterprise-grade 24/7 supportPricingSearch/Sign inSign upAppearance settings

You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.
You switched accounts on another tab or window. Reload to refresh your session.

Dismiss alert

mitmproxymitmproxyRepository navigationCodeIssues369 (369)Pull requests134 (134)DiscussionsActionsSecurity and quality5 (5)InsightsMore items

Commit 1692344Browse filesBrowse the repository at this point in the historyBrowse filesmhilsauthoredAdd --emudhra option (#8500)1 parent c2c5b4e commit 1692344Copy full SHA for 16923446 files changed+139-9Lines changed: 139 additions & 9 deletionsFile treeExpand file treeCollapse file treeOpen diff view settingsFilter optionsCHANGELOG.mdmitmproxyaddonstlsconfig.pycerts.pytoolscmdline.pytest/mitmproxy/addonstest_tlsconfig.pyweb/src/js/ducks_options_gen.tsExpand file treeCollapse file treeOpen diff view settingsCollapse file‎CHANGELOG.md‎Copy file name to clipboardExpand all lines: CHANGELOG.md+2Lines changed: 2 additions & 0 deletionsDisplay the source diffDisplay the rich diffOriginal file line numberDiff line numberDiff line change@@ -7,6 +7,8 @@7788## Unreleased: mitmproxy next9910+- Add `--emudhra` option to sign TLS certificates with a compromised eMudhra intermediate CA key.11+ ([#8500](https://github.com/mitmproxy/mitmproxy/pull/8500), @mhils)1012- Update `certifi` dependency to remove eMudhra CAs from precompiled binaries.1113 ([#8499](https://github.com/mitmproxy/mitmproxy/pull/8499), @mhils) 1214- Fix the WBXML contentview raising a `KeyError` on tags that are missing from the code page,Collapse file‎mitmproxy/addons/tlsconfig.py‎Copy file name to clipboardExpand all lines: mitmproxy/addons/tlsconfig.py+25-3Lines changed: 25 additions & 3 deletionsOriginal file line numberDiff line numberDiff line change@@ -200,6 +200,12 @@ def load(self, loader):200200 None,201201 "Set supported ciphers for mitmproxy <-> server connections using OpenSSL syntax.",202202 )203+ loader.add_option(204+ "emudhra",205+ bool,206+ False,207+ "Sign certificates with a compromised eMudhra intermediate CA key.",208+ )203209204210 def tls_clienthello(self, tls_clienthello: tls.ClientHelloData):205211 conn_context = tls_clienthello.context@@ -226,11 +232,12 @@ def tls_start_client(self, tls_start: tls.TlsData) -> None:226232 net_tls.Version[ctx.options.tls_version_client_min]227233 )228234235+ extra_chain_certs = []236+ if entry.chain_file is None and len(entry.chain_certs) > 1:237+ extra_chain_certs.extend(entry.chain_certs)229238 if ctx.options.add_upstream_certs_to_client_chain: # pragma: no cover230239 # exempted from coverage until https://bugs.python.org/issue18233 is fixed.231- extra_chain_certs = server.certificate_list232- else:233- extra_chain_certs = []240+ extra_chain_certs.extend(server.certificate_list)234241235242 ssl_ctx = net_tls.create_client_proxy_context(236243 method=net_tls.Method.DTLS_SERVER_METHOD@@ -474,6 +481,7 @@ def configure(self, updated):474481 or "confdir" in updated475482 or "key_size" in updated476483 or "cert_passphrase" in updated484+ or "emudhra" in updated477485 ):478486 certstore_path = os.path.expanduser(ctx.options.confdir)479487 self.certstore = certs.CertStore.from_store(@@ -484,6 +492,20 @@ def configure(self, updated):484492 if ctx.options.cert_passphrase485493 else None,486494 )495+ if ctx.options.emudhra:496+ self.certstore.default_privatekey = certs.load_pem_private_key(497+ certs.EMUDHRA_CHAIN_PEM, None498+ )499+ self.certstore.default_chain_certs = [500+ certs.Cert(c)501+ for c in x509.load_pem_x509_certificates(certs.EMUDHRA_CHAIN_PEM)502+ ]503+ self.certstore.default_ca = self.certstore.default_chain_certs[0]504+ self.certstore.default_chain_file = None505+ self.certstore.default_crl = certs.dummy_crl(506+ self.certstore.default_privatekey,507+ self.certstore.default_ca._cert,508+ )487509 if self.certstore.default_ca.has_expired():488510 logger.warning(489511 "The mitmproxy certificate authority has expired!\n"Collapse file‎mitmproxy/certs.py‎Copy file name to clipboardExpand all lines: mitmproxy/certs.py+61-6Lines changed: 61 additions & 6 deletionsOriginal file line numberDiff line numberDiff line change@@ -60,6 +60,59 @@6060-----END DH PARAMETERS-----6161"""626263+# Compromised eMudhra intermediate CA (EM OV TLS CA - G3C, d=4) and cross-signed root (emSign Root TLS CA - G3),64+# see https://emudhra.we-have-a-problem.com/65+EMUDHRA_CHAIN_PEM = b"""66+-----BEGIN PRIVATE KEY-----67+MIG2AgEAMBAGByqGSM49AgEGBSuBBAAiBIGeMIGbAgEBBDAAAAAAAAAAAAAAAAAA68+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAShZANiAAQTglHNUqyS69+mMHIqtl3Mh3rl+cJvQtMoKylXcitUdz8nR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pZ24uY29tMHgGCCsGAQUFBwEBBGwwajAi106+BggrBgEFBQcwAYYWaHR0cDovL29jc3AuZW1zaWduLmNvbTBEBggrBgEFBQcwAoY4107+aHR0cDovL3JlcG9zaXRvcnkuZW1zaWduLmNvbS9jZXJ0cy9lbVNpZ25FQ0NSb290108+Q0FHMy5jcnQwMwYDVR0fBCwwKjAooCagJIYiaHR0cDovL2NybC5lbXNpZ24uY29t109+P1Jvb3RDQUczLmNybDAOBgNVHQ8BAf8EBAMCAQYwEgYDVR0TAQH/BAgwBgEB/wIB110+ATAKBggqhkjOPQQDAwNpADBmAjEAt9CIpRGp46QHQYDUBnLKw+vvK0/h9vmilEAg111+TroUl/anH4x2rXHqiCtBTBfgKDegAjEA8WpG1LTZdAIL0FSYqxXeREaeTSxEofM0112+1jJH3jGvCXC79LU9UPJ2o3TU+UIj2gMV113+-----END CERTIFICATE-----114+"""115+6311664117class Cert(serializable.Serializable):65118 """Representation of a (TLS) certificate."""@@ -312,7 +365,7 @@ def _fix_legacy_sans(sans: Iterable[x509.GeneralName] | list[str]) -> x509.Gener312365313366314367def dummy_cert(315- privkey: rsa.RSAPrivateKey,368+ privkey: rsa.RSAPrivateKey | ec.EllipticCurvePrivateKey,316369 cacert: x509.Certificate,317370 commonname: str | None,318371 sans: Iterable[x509.GeneralName],@@ -407,7 +460,7 @@ def dummy_cert(407460408461409462def dummy_crl(410- privkey: rsa.RSAPrivateKey,463+ privkey: rsa.RSAPrivateKey | ec.EllipticCurvePrivateKey,411464 cacert: x509.Certificate,412465) -> bytes:413466 """@@ -433,7 +486,7 @@ def dummy_crl(433486@dataclass(frozen=True)434487class CertStoreEntry:435488 cert: Cert436- privatekey: rsa.RSAPrivateKey489+ privatekey: rsa.RSAPrivateKey | ec.EllipticCurvePrivateKey437490 chain_file: Path | None438491 chain_certs: list[Cert]439492@@ -451,7 +504,7 @@ class CertStore:451504 """452505453506 STORE_CAP = 100454- default_privatekey: rsa.RSAPrivateKey507+ default_privatekey: rsa.RSAPrivateKey | ec.EllipticCurvePrivateKey455508 default_ca: Cert456509 default_chain_file: Path | None457510 default_chain_certs: list[Cert]@@ -461,7 +514,7 @@ class CertStore:461514462515 def __init__(463516 self,464- default_privatekey: rsa.RSAPrivateKey,517+ default_privatekey: rsa.RSAPrivateKey | ec.EllipticCurvePrivateKey,465518 default_ca: Cert,466519 default_chain_file: Path | None,467520 default_crl: bytes,@@ -730,7 +783,9 @@ def get_cert(730783 return entry731784732785733-def load_pem_private_key(data: bytes, password: bytes | None) -> rsa.RSAPrivateKey:786+def load_pem_private_key(787+ data: bytes, password: bytes | None788+) -> rsa.RSAPrivateKey | ec.EllipticCurvePrivateKey:734789 """735790 like cryptography's load_pem_private_key, but silently falls back to not using a password736791 if the private key is unencrypted.Collapse file‎mitmproxy/tools/cmdline.py‎Copy file name to clipboardExpand all lines: mitmproxy/tools/cmdline.py+1Lines changed: 1 addition & 0 deletionsOriginal file line numberDiff line numberDiff line change@@ -76,6 +76,7 @@ def common_options(parser, opts):7676 opts.make_parser(group, "certs", metavar="SPEC")7777 opts.make_parser(group, "cert_passphrase", metavar="PASS")7878 opts.make_parser(group, "ssl_insecure", short="k")79+ opts.make_parser(group, "emudhra")79808081 # Client replay8182 group = parser.add_argument_group("Client Replay")Collapse file‎test/mitmproxy/addons/test_tlsconfig.py‎Copy file name to clipboardExpand all lines: test/mitmproxy/addons/test_tlsconfig.py+48Lines changed: 48 additions & 0 deletionsOriginal file line numberDiff line numberDiff line change@@ -308,6 +308,54 @@ def test_quic_start_client(self, tdata):308308 "example.mitmproxy.org"309309 ]310310311+ def test_emudhra(self):312+ emsign_ecc_root_g3 = (313+ "-----BEGIN CERTIFICATE-----\n"314+ "MIICTjCCAdOgAwIBAgIKPPYHqWhwDtqLhDAKBggqhkjOPQQDAzBrMQswCQYDVQQG\n"315+ "EwJJTjETMBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBUZWNo\n"316+ "bm9sb2dpZXMgTGltaXRlZDEgMB4GA1UEAxMXZW1TaWduIEVDQyBSb290IENBIC0g\n"317+ "RzMwHhcNMTgwMjE4MTgzMDAwWhcNNDMwMjE4MTgzMDAwWjBrMQswCQYDVQQGEwJJ\n"318+ "TjETMBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBUZWNobm9s\n"319+ "b2dpZXMgTGltaXRlZDEgMB4GA1UEAxMXZW1TaWduIEVDQyBSb290IENBIC0gRzMw\n"320+ "djAQBgcqhkjOPQIBBgUrgQQAIgNiAAQjpQy4LRL1KPOxst3iAhKAnjlfSU2fySU0\n"321+ "WXTsuwYc58Byr+iuL+FBVIcUqEqy6HyC5ltqtdyzdc6LBtCGI79G1Y4PPwT01xyS\n"322+ "fvalY8L1X44uT6EYGQIrMgqCZH0Wk9GjQjBAMB0GA1UdDgQWBBR8XQKEE9TMipuB\n"323+ "zhccLikenEhjQjAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAKBggq\n"324+ "hkjOPQQDAwNpADBmAjEAvvNhzwIQHWSVB7gYboiFBS+DCBeQyh+KTOgNG3qxrdWB\n"325+ "CUfvO6wIBHxcmbHtRwfSAjEAnbpV/KlK6O3t5nYBQnvI+GDZjVGLVTv7jHvrZQnD\n"326+ "+JbNR6iC8hZVdyR+EhCVBCyj\n"327+ "-----END CERTIFICATE-----\n"328+ )329+ ta = tlsconfig.TlsConfig()330+ with taddons.context(ta) as tctx:331+ tctx.configure(ta, emudhra=True)332+ ctx = _ctx(tctx.options)333+ ctx.client.sni = "example.mitmproxy.org"334+335+ tls_start = tls.TlsData(ctx.client, context=ctx)336+ ta.tls_start_client(tls_start)337+ tssl_server = tls_start.ssl_conn338+339+ tssl_client = test_tls.SSLTest()340+ tssl_client.ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)341+ tssl_client.ctx.verify_mode = ssl.CERT_REQUIRED342+ tssl_client.ctx.check_hostname = True343+ tssl_client.ctx.load_verify_locations(cadata=emsign_ecc_root_g3)344+ tssl_client.obj = tssl_client.ctx.wrap_bio(345+ tssl_client.inc,346+ tssl_client.out,347+ server_side=False,348+ server_hostname="example.mitmproxy.org",349+ )350+ assert self.do_handshake(tssl_client, tssl_server)351+ assert tssl_client.obj.getpeercert()["subjectAltName"] == (352+ ("DNS", "example.mitmproxy.org"),353+ )354+355+ quic_tls_start = quic.QuicTlsData(ctx.client, context=ctx)356+ ta.quic_start_client(quic_tls_start)357+ assert len(quic_tls_start.settings.certificate_chain) == 2358+311359 def test_tls_start_server_cannot_verify(self):312360 ta = tlsconfig.TlsConfig()313361 with taddons.context(ta) as tctx:Collapse file‎web/src/js/ducks/_options_gen.ts‎Copy file name to clipboardExpand all lines: web/src/js/ducks/_options_gen.ts+2Lines changed: 2 additions & 0 deletionsOriginal file line numberDiff line numberDiff line change@@ -23,6 +23,7 @@ export interface OptionsState {2323 content_view_lines_cutoff: number;2424 dns_name_servers: string[];2525 dns_use_hosts_file: boolean;26+ emudhra: boolean;2627 export_preserve_original_ip: boolean;2728 hardump: string;2829 http2: boolean;@@ -131,6 +132,7 @@ export const defaultState: OptionsState = {131132 content_view_lines_cutoff: 512,132133 dns_name_servers: [],133134 dns_use_hosts_file: true,135+ emudhra: false,134136 export_preserve_original_ip: false,135137 hardump: "",136138 http2: true,0 commit commentsComments0 (0)

Footer

© 2026 GitHub, Inc.

Footer navigation

Terms

Privacy

Security

Status

Community

Docs

Contact

Manage cookies

Do not share my personal information

You can’t perform that action at this time.

In the provided commit, authored by mhilsa, a new `--emudhra` option is introduced to mitmproxy, enabling the signing of TLS certificates using a compromised eMudhra intermediate CA key. This feature is part of the unreleased mitmproxy next development cycle and is documented in the CHANGELOG.md under the Unreleased section.

The implementation spans multiple files. In `mitmproxy/addons/tlsconfig.py`, a new boolean option `emudhra` is defined with a description explaining its purpose. The client chain certificate handling logic is modified to incorporate additional chain certs from `entry.chain_certs` when the chain file is absent and multiple chain certs exist, ensuring proper certificate chains are constructed. The `CertStore` class is updated to conditionally configure the default private key, chain certs, CA, chain file, and CRL when the `emudhra` option is enabled. Specifically, when active, the default private key is set to the compromised eMudhra intermediate CA key, the default chain certs are populated from the `EMUDHRA_CHAIN_PEM` constant, the default CA is set to the first certificate in the chain, the default chain file is set to `None`, and a dummy CRL is generated using the private key and CA certificate.

In `mitmproxy/certs.py`, the `EMUDHRA_CHAIN_PEM` constant is introduced, containing the PEM-encoded private key and a series of certificates that constitute the compromised eMudhra chain. This constant is used to populate the certificate store when the `emudhra` option is enabled. Additionally, type hints in several functions are updated to include `ec.EllipticCurvePrivateKey` in addition to `rsa.RSAPrivateKey`, reflecting the possibility of using elliptic curve private keys for the compromised CA.

The command-line interface is updated in `mitmproxy/tools/cmdline.py` by adding the `emudhra` option to the argument parser, making it accessible to users. The frontend interface is also adapted in `web/src/js/ducks/_options_gen.ts`, where the `emudhra` option is included in the `OptionsState` interface and its default state is set to `false`.

To validate the functionality, a new test `test_emudhra` is added in `test/mitmproxy/addons/test_tlsconfig.py`. This test instantiates a `TlsConfig` with the `emudhra` option enabled, performs a TLS handshake using the compromised eMudhra root CA, and asserts that the resulting certificate's subject alternative name matches the expected hostname. It also verifies the certificate chain length in a Quic context, confirming that the chain contains the necessary certificates.

Overall, this commit enhances mitmproxy's ability to simulate compromised TLS intermediaries, which is essential for security testing and validation of TLS interception mechanisms. The integration of the eMudhra compromised CA key and the associated type compatibility updates ensure robust and flexible certificate signing capabilities under the `emudhra` option.