{"action":"created","issue":{"url":"https://api.github.com/repos/golang/go/issues/10490","labels_url":"https://api.github.com/repos/golang/go/issues/10490/labels{/name}","comments_url":"https://api.github.com/repos/golang/go/issues/10490/comments","events_url":"https://api.github.com/repos/golang/go/issues/10490/events","html_url":"https://github.com/golang/go/issues/10490","id":69137174,"number":10490,"title":"encoding/gob: excessive memory consumption","user":{"login":"dvyukov","id":1095328,"avatar_url":"https://avatars.githubusercontent.com/u/1095328?v=3","gravatar_id":"","url":"https://api.github.com/users/dvyukov","html_url":"https://github.com/dvyukov","followers_url":"https://api.github.com/users/dvyukov/followers","following_url":"https://api.github.com/users/dvyukov/following{/other_user}","gists_url":"https://api.github.com/users/dvyukov/gists{/gist_id}","starred_url":"https://api.github.com/users/dvyukov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dvyukov/subscriptions","organizations_url":"https://api.github.com/users/dvyukov/orgs","repos_url":"https://api.github.com/users/dvyukov/repos","events_url":"https://api.github.com/users/dvyukov/events{/privacy}","received_events_url":"https://api.github.com/users/dvyukov/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":{"login":"robpike","id":4324516,"avatar_url":"https://avatars.githubusercontent.com/u/4324516?v=3","gravatar_id":"","url":"https://api.github.com/users/robpike","html_url":"https://github.com/robpike","followers_url":"https://api.github.com/users/robpike/followers","following_url":"https://api.github.com/users/robpike/following{/other_user}","gists_url":"https://api.github.com/users/robpike/gists{/gist_id}","starred_url":"https://api.github.com/users/robpike/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robpike/subscriptions","organizations_url":"https://api.github.com/users/robpike/orgs","repos_url":"https://api.github.com/users/robpike/repos","events_url":"https://api.github.com/users/robpike/events{/privacy}","received_events_url":"https://api.github.com/users/robpike/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/golang/go/milestones/1","html_url":"https://github.com/golang/go/milestones/Go1.5","labels_url":"https://api.github.com/repos/golang/go/milestones/1/labels","id":905105,"number":1,"title":"Go1.5","description":"","creator":{"login":"bradfitz","id":2621,"avatar_url":"https://avatars.githubusercontent.com/u/2621?v=3","gravatar_id":"","url":"https://api.github.com/users/bradfitz","html_url":"https://github.com/bradfitz","followers_url":"https://api.github.com/users/bradfitz/followers","following_url":"https://api.github.com/users/bradfitz/following{/other_user}","gists_url":"https://api.github.com/users/bradfitz/gists{/gist_id}","starred_url":"https://api.github.com/users/bradfitz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bradfitz/subscriptions","organizations_url":"https://api.github.com/users/bradfitz/orgs","repos_url":"https://api.github.com/users/bradfitz/repos","events_url":"https://api.github.com/users/bradfitz/events{/privacy}","received_events_url":"https://api.github.com/users/bradfitz/received_events","type":"User","site_admin":false},"open_issues":283,"closed_issues":577,"state":"open","created_at":"2014-12-16T02:26:41Z","updated_at":"2015-06-02T15:27:31Z","due_on":"2015-07-31T04:00:00Z","closed_at":null},"comments":13,"created_at":"2015-04-17T13:19:15Z","updated_at":"2015-06-02T18:17:42Z","closed_at":"2015-06-02T15:27:31Z","body":"go version devel +8ea2438 Fri Apr 17 13:44:30 2015 +0300 linux/amd64\r\nwith https://go-review.googlesource.com/#/c/8942/ appled.\r\n\r\nThe following program consumes 2GB while the input is few bytes. I suspect it is possible to modify the input to force the program to allocate arbitrary amount of memory and run for arbitrary period of time.\r\n\r\nAllocations happen while receiving a wire type (encoding/gob.(*Decoder).recvType).\r\n\r\n```go\r\npackage main\r\n\r\nimport (\r\n\t\"bytes\"\r\n\t\"encoding/gob\"\r\n\t\"encoding/hex\"\r\n)\r\n\r\ntype X struct {\r\n}\r\n\r\nfunc main() {\r\n\tdata, _ := hex.DecodeString(\"53ff8f03010106696e7075745401ff900001fc0701044d61786901040001044d\" +\r\n\t\t\"696e6901040001044d61787501060001044d61786601080001044d696e660108\" +\r\n\t\t\"0001044d617863010e0001044d696e63010e00000007ff9001fe0000\")\r\n\ts := \"\"\r\n\tgob.NewDecoder(bytes.NewReader(data)).Decode(&s)\r\n\tvar b []byte\r\n\tgob.NewDecoder(bytes.NewReader(data)).Decode(&b)\r\n\tvar f float64\r\n\tgob.NewDecoder(bytes.NewReader(data)).Decode(&f)\r\n\tvar x X\r\n\tgob.NewDecoder(bytes.NewReader(data)).Decode(&x)\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/golang/go/issues/comments/108040803","html_url":"https://github.com/golang/go/issues/10490#issuecomment-108040803","issue_url":"https://api.github.com/repos/golang/go/issues/10490","id":108040803,"user":{"login":"robpike","id":4324516,"avatar_url":"https://avatars.githubusercontent.com/u/4324516?v=3","gravatar_id":"","url":"https://api.github.com/users/robpike","html_url":"https://github.com/robpike","followers_url":"https://api.github.com/users/robpike/followers","following_url":"https://api.github.com/users/robpike/following{/other_user}","gists_url":"https://api.github.com/users/robpike/gists{/gist_id}","starred_url":"https://api.github.com/users/robpike/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robpike/subscriptions","organizations_url":"https://api.github.com/users/robpike/orgs","repos_url":"https://api.github.com/users/robpike/repos","events_url":"https://api.github.com/users/robpike/events{/privacy}","received_events_url":"https://api.github.com/users/robpike/received_events","type":"User","site_admin":false},"created_at":"2015-06-02T18:17:42Z","updated_at":"2015-06-02T18:17:42Z","body":"A slice can in general require as many messages as there are elements. Therefore it is not easy to say, this message is too short for the slice data. As I said above, it's feasible to check for certain slice types but not all, so I don't believe it's worth doing at all since it can't be done properly."}}