{"action":"opened","issue":{"url":"https://api.github.com/repos/lovell/sharp/issues/1331","repository_url":"https://api.github.com/repos/lovell/sharp","labels_url":"https://api.github.com/repos/lovell/sharp/issues/1331/labels{/name}","comments_url":"https://api.github.com/repos/lovell/sharp/issues/1331/comments","events_url":"https://api.github.com/repos/lovell/sharp/issues/1331/events","html_url":"https://github.com/lovell/sharp/issues/1331","id":350001437,"node_id":"MDU6SXNzdWUzNTAwMDE0Mzc=","number":1331,"title":"Possible image data leak when resizing a transparent GIF","user":{"login":"makepanic","id":1205444,"node_id":"MDQ6VXNlcjEyMDU0NDQ=","avatar_url":"https://avatars3.githubusercontent.com/u/1205444?v=4","gravatar_id":"","url":"https://api.github.com/users/makepanic","html_url":"https://github.com/makepanic","followers_url":"https://api.github.com/users/makepanic/followers","following_url":"https://api.github.com/users/makepanic/following{/other_user}","gists_url":"https://api.github.com/users/makepanic/gists{/gist_id}","starred_url":"https://api.github.com/users/makepanic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/makepanic/subscriptions","organizations_url":"https://api.github.com/users/makepanic/orgs","repos_url":"https://api.github.com/users/makepanic/repos","events_url":"https://api.github.com/users/makepanic/events{/privacy}","received_events_url":"https://api.github.com/users/makepanic/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-08-13T12:04:23Z","updated_at":"2018-08-13T12:04:23Z","closed_at":null,"author_association":"NONE","body":"Hi there,\r\nI'm seeing leaked image data when resizing a transparent GIF image.\r\n\r\nI'm unsure if this is a issue with sharp/vips or the loader that handles GIF images.\r\nIt looks like the content of resizes leak into the resize of transparent GIF images.\r\n\r\nHere's the output of resizing one png and a gif multiple times:\r\n\r\n(with flatten):\r\n![20180813-130825](https://user-images.githubusercontent.com/1205444/44030312-b7f28212-9f00-11e8-8d59-b08d39e8a856.png)\r\n\r\n(without flatten):\r\n![20180813-130801](https://user-images.githubusercontent.com/1205444/44030440-139d6942-9f01-11e8-9479-1668baaed56d.png)\r\n\r\nAfter transforming the png, each transformation of the transparent gif leaks leaks some information. In this minimal case, it's pretty uncommon but we've seen worse in production.\r\n\r\nIs this a known issue that once can possibly fix by using a different configuration?\r\nTrying to reproduce it with a transparent png, it doesn't happen :thinking: \r\n\r\nHere's the minimal setup for the above output (note it will result in slightly different images depending on your system).\r\n\r\n```js\r\nconst sharp = require(\"sharp\");\r\nconst fs = require(\"fs\");\r\n\r\nconst fA = \"top-secret.png\";\r\nconst fB = \"transparent.gif\";\r\n\r\nlet counter = 0;\r\n\r\nfunction transform(fileName) {\r\n  return new Promise(resolve => {\r\n    const resizer = sharp()\r\n      .flatten(true)\r\n      .rotate()\r\n      .toFormat(\"png\")\r\n      .resize(300, 400)\r\n      .min()\r\n      .crop(sharp.gravity.center);\r\n\r\n    const writeStream = fs.createWriteStream(\r\n      `./outputs/${fileName}.${counter}.png`\r\n    );\r\n\r\n    writeStream.on(\"close\", () => {\r\n      counter++;\r\n      resolve();\r\n    });\r\n\r\n    fs.createReadStream(`./inputs/${fileName}`)\r\n      .pipe(resizer)\r\n      .pipe(writeStream);\r\n  });\r\n}\r\n\r\nasync function main() {\r\n  await transform(fA);\r\n  await transform(fB);\r\n  await transform(fB);\r\n  await transform(fB);\r\n  await transform(fB);\r\n  await transform(fB);\r\n  await transform(fB);\r\n  await transform(fB);\r\n  await transform(fB);\r\n  await transform(fB);\r\n  await transform(fB);\r\n  await transform(fB);\r\n  await transform(fB);\r\n  await transform(fB);\r\n  await transform(fB);\r\n}\r\n\r\nmain().catch(e => console.error(e));\r\n```\r\n\r\nHere are the given inputs:\r\n![transparent](https://user-images.githubusercontent.com/1205444/44030474-37271a0c-9f01-11e8-8049-018505eedadb.gif)\r\n![top-secret](https://user-images.githubusercontent.com/1205444/44030475-3746a728-9f01-11e8-82c5-c4bc4cd10f14.png)\r\n\r\nDo you have any ideas or suggestions on how to proceed with this?\r\n\r\nThanks\r\n"}}
{"actor":{"display_login":"makepanic"}}