{"id":7246,"date":"2021-02-08T13:27:31","date_gmt":"2021-02-08T13:27:31","guid":{"rendered":"https:\/\/www.version1.com\/en-us\/?p=7246"},"modified":"2021-02-08T13:27:31","modified_gmt":"2021-02-08T13:27:31","slug":"ec2-metadata-evil-or-genius","status":"publish","type":"post","link":"https:\/\/www.version1.com\/en-us\/ec2-metadata-evil-or-genius\/","title":{"rendered":"EC2 Metadata: Evil or Genius?"},"content":{"rendered":"<p>Regular listeners to BBC Radio 4 may be familiar with the \u201cEvil Genius\u201d series, in which Russell Kane, assisted by a panel of expert and celebrity guests, weighs iconic figures in the balance to establish whether they were truly evil or truly genius.<\/p>\n<p>I would like to pick up that idea and run with it for a while, but apply it to something a little closer to home for your run-of-the-mill IT folk \u2014 the metadata available in an AWS EC2 instance. Before delving into the technical ins and outs of EC2 metadata, let us first look at what metadata is, in general terms. The prefix \u2018meta-\u2018 is derived from the Greek word meaning \u2018after\u2019 or \u2018beyond\u2019, and came to prominence in terms such as \u2018metamathematics\u2019 and \u2018metaphysics\u2019 to denote a field of study of the underlying base subject.<\/p>\n<p>Meta- has sprawled impressively into many parts of the English language to mean anything that is \u2018about\u2019 something else, giving us meta-rules (rules about the application of rules), metaprogramming (where programs feed on other programs), but not Metaxa, which is a half-decent Greek brandy. Metadata then, is data about data; the author and date of publication of a book, for example, with the contents of the book being the data itself, or is that themselves what with data being a plural? Hello, fellow nit-pickers.<\/p>\n<p>Enough of these amuse-bouches, let us get our teeth into the main course \u2014 EC2 metadata, what is it, what can we use it for and most importantly, is it evil or genius?<\/p>\n<p><strong>What is it?<\/strong><\/p>\n<p>It\u2019s data about your EC2 instances (of course, we guessed that from the long-winded explication above, right?), accessible inside each instance and provided by the instance metadata service (IMDS). You can access the metadata by \u201cbrowsing\u201d to http:\/\/169.254.169.254\/latest\/metadata\/ from within your instance. This will return a list of categories that you can drill down into to reveal all sorts of interesting stuff about your instance that is not immediately available from within the operating system itself. With that in mind let us move on to look at\u2026<br \/>\nWhat can we do with it?<\/p>\n<p><strong>Want to know the public IP address of your instance without looking it up on the console?<\/strong><br \/>\n<em>curl http:\/\/169.254.169.254\/latest\/metadata\/public-ipv4 will tell you what you want to know.<\/em><\/p>\n<p><strong>What AMI did I use to launch this instance?<\/strong><br \/>\n<em>curl http:\/\/169.254.169.254\/latest\/metadata\/ami-id is your friend.<\/em><\/p>\n<p><strong>Did I really launch my instance in Bahrain?!<\/strong><br \/>\n<em>curl http:\/\/169.254.169.254\/latest\/metadata\/placement\/availability-zone will set your mind at rest.<\/em><\/p>\n<p>\u201cThat seems like a lot of information to have lying around\u201d, I hear you say. \u201cIs it secure?\u201d. Well, the answer is yes and no, which might have been anticipated from the tone of this post.<\/p>\n<p><strong>Evil or Genius?<\/strong><\/p>\n<p>It might be assumed that a URL that is only accessible on a private, local address would be secure, however, if we imagine a scenario where the instance is running a service which is presented to the outside world, things become a little less clear-cut. Enter \u2026 Server-Side Request Forgery, or SSRF for short. SSRF is a means of forcing an application to make a call to a system or service that it was not designed to, usually with undesirable consequences. It is often exploited in connection with a web application carrying out import or export operations, such as sending a printable report in PDF or uploading an image. If the application does not carry out sufficient checks on the type and endpoint of such transfers, then they can be exploited to retrieve information that should not normally be visible.<\/p>\n<p>In mid-2019, just such an exploit was carried out against Capital One, resulting in the leakage of personal details for 100 million existing customers and prospective cardholders. The attacker, who had a bona fide Capital One online account, noticed that the process to upload and preview a custom image for printing to your new credit card made use of an AWS S3 bucket, the URL of which was specified as a sub-component of the upload-image URL. By crafting a new \u201csub-URL\u201d which pointed instead to the application instance\u2019s metadata source, she was able to siphon off the instance\u2019s IAM Role access keys and then use these to access and scan a large number of S3 buckets, downloading personal information on millions of people. This breach has been modelled by Kontra as an instructional exercise: Capital One SSRF | Kontra, allowing you to step into the shoes of the hacker responsible and gain a better understanding of how the vulnerability was discovered and exploited.<\/p>\n<p>In and of itself then, Instance Metadata seems reasonably secure and is demonstrably useful. Add a sloppily-constructed application into the mix, one which does not check its inputs and outputs thoroughly, and suddenly metadata is sliding into a dark place.<\/p>\n<p>Depending on how secure you want things to be, a number of options present themselves.<\/p>\n<p>At the most extreme, the instance metadata service can be simply disabled.<\/p>\n<p>If you still have a requirement for metadata, a newer, more secure flavour, cunningly called IMDSv2 is available. Using it allows you to block access to the older, less secure version and use a time-bound, token-based access method. Essentially you \u2018unlock\u2019 an instance metadata session for a fixed period of time (between one second and six hours), do what you need to do, and IMDS access stops working when the token expires. For details, see Configure the instance metadata service \u2014 Amazon Elastic Compute Cloud<br \/>\nOr stick with good old IMDSv1 and use an application with no security flaws. Simple.<\/p>\n<p><strong>About the Author<\/strong><\/p>\n<p>Alex Collier is currently a DevOps Cloud Engineer at Version 1.<\/p>\n<p><strong>About Version 1<\/strong><\/p>\n<p><em>Version 1 is a leader in Enterprise Cloud services and was one of the first AWS Consulting Partners in Europe. We are an AWS Premier Partner and specialise in\u00a0<\/em><em>migrating and running complex enterprise workloads in Public Cloud. Version 1 is a leader in Enterprise Cloud services and was one of the first AWS Consulting Partners in Europe. We have a policy of continuous investment in technology solutions that benefit our customers and are in the small number Amazon Web Services Partners to have achieved advanced partner status. Our team works closely with AWS to help our customers navigate the rapidly changing world of IT.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Regular listeners to BBC Radio 4 may be familiar with the \u201cEvil Genius\u201d series, in which Russell Kane, assisted by a panel of expert and celebrity guests, weighs iconic figures in the balance to establish whether they were truly evil or truly genius. I would like to pick up that idea and run with it [&hellip;]<\/p>\n","protected":false},"author":0,"featured_media":7247,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"content-type":"","inline_featured_image":false,"footnotes":""},"categories":[101],"tags":[125],"industry":[],"class_list":["post-7246","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-aws"],"acf":[],"translations":[{"blog_id":1,"post_id":7246,"name":"Europe","code":"EN-GB","hreflang":"en-gb","url":"https:\/\/www.version1.com\/blog\/ec2-metadata-evil-or-genius\/","is_current":false},{"blog_id":13,"post_id":7246,"name":"Americas","code":"EN-US","hreflang":"en-us","url":"https:\/\/www.version1.com\/en-us\/ec2-metadata-evil-or-genius\/","is_current":true}],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>EC2 Metadata: Evil or Genius? | Version 1 (US)<\/title>\n<meta name=\"description\" content=\"Regular listeners to BBC Radio 4 may be familiar with the \u201cEvil Genius\u201d series, in which Russell Kane, assisted by a panel of expert and celebrity guests, One of our consultants here at Version 1 has explored EC2 metadata and explained what it is, what can we use it for and, is it evil or genius?\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.version1.com\/en-us\/ec2-metadata-evil-or-genius\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"EC2 Metadata: Evil or Genius? | Version 1 (US)\" \/>\n<meta property=\"og:description\" content=\"Regular listeners to BBC Radio 4 may be familiar with the \u201cEvil Genius\u201d series, in which Russell Kane, assisted by a panel of expert and celebrity guests, One of our consultants here at Version 1 has explored EC2 metadata and explained what it is, what can we use it for and, is it evil or genius?\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.version1.com\/en-us\/ec2-metadata-evil-or-genius\/\" \/>\n<meta property=\"og:site_name\" content=\"Version 1 (US)\" \/>\n<meta property=\"article:published_time\" content=\"2021-02-08T13:27:31+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.version1.com\/en-us\/wp-content\/uploads\/2021\/02\/laptop-user.jpg.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"680\" \/>\n\t<meta property=\"og:image:height\" content=\"440\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.version1.com\\\/en-us\\\/ec2-metadata-evil-or-genius\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.version1.com\\\/en-us\\\/ec2-metadata-evil-or-genius\\\/\"},\"author\":{\"name\":\"\",\"@id\":\"\"},\"headline\":\"EC2 Metadata: Evil or Genius?\",\"datePublished\":\"2021-02-08T13:27:31+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.version1.com\\\/en-us\\\/ec2-metadata-evil-or-genius\\\/\"},\"wordCount\":1049,\"publisher\":{\"@id\":\"https:\\\/\\\/www.version1.com\\\/en-us\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.version1.com\\\/en-us\\\/ec2-metadata-evil-or-genius\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.version1.com\\\/en-us\\\/wp-content\\\/uploads\\\/2021\\\/02\\\/laptop-user.jpg.webp\",\"keywords\":[\"AWS\"],\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.version1.com\\\/en-us\\\/ec2-metadata-evil-or-genius\\\/\",\"url\":\"https:\\\/\\\/www.version1.com\\\/en-us\\\/ec2-metadata-evil-or-genius\\\/\",\"name\":\"EC2 Metadata: Evil or Genius? | Version 1 (US)\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.version1.com\\\/en-us\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.version1.com\\\/en-us\\\/ec2-metadata-evil-or-genius\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.version1.com\\\/en-us\\\/ec2-metadata-evil-or-genius\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.version1.com\\\/en-us\\\/wp-content\\\/uploads\\\/2021\\\/02\\\/laptop-user.jpg.webp\",\"datePublished\":\"2021-02-08T13:27:31+00:00\",\"description\":\"Regular listeners to BBC Radio 4 may be familiar with the \u201cEvil Genius\u201d series, in which Russell Kane, assisted by a panel of expert and celebrity guests, One of our consultants here at Version 1 has explored EC2 metadata and explained what it is, what can we use it for and, is it evil or genius?\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.version1.com\\\/en-us\\\/ec2-metadata-evil-or-genius\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.version1.com\\\/en-us\\\/ec2-metadata-evil-or-genius\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.version1.com\\\/en-us\\\/ec2-metadata-evil-or-genius\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.version1.com\\\/en-us\\\/wp-content\\\/uploads\\\/2021\\\/02\\\/laptop-user.jpg.webp\",\"contentUrl\":\"https:\\\/\\\/www.version1.com\\\/en-us\\\/wp-content\\\/uploads\\\/2021\\\/02\\\/laptop-user.jpg.webp\",\"width\":680,\"height\":440,\"caption\":\"person sat at desk in front of laptop and monitor\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.version1.com\\\/en-us\\\/ec2-metadata-evil-or-genius\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.version1.com\\\/en-us\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"EC2 Metadata: Evil or Genius?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.version1.com\\\/en-us\\\/#website\",\"url\":\"https:\\\/\\\/www.version1.com\\\/en-us\\\/\",\"name\":\"Version 1\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.version1.com\\\/en-us\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.version1.com\\\/en-us\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.version1.com\\\/en-us\\\/#organization\",\"name\":\"Version 1\",\"url\":\"https:\\\/\\\/www.version1.com\\\/en-us\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.version1.com\\\/en-us\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.version1.com\\\/wp-content\\\/uploads\\\/2026\\\/05\\\/cropped-cropped-Favicon-2.png\",\"contentUrl\":\"https:\\\/\\\/www.version1.com\\\/wp-content\\\/uploads\\\/2026\\\/05\\\/cropped-cropped-Favicon-2.png\",\"width\":512,\"height\":512,\"caption\":\"Version 1\"},\"image\":{\"@id\":\"https:\\\/\\\/www.version1.com\\\/en-us\\\/#\\\/schema\\\/logo\\\/image\\\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"EC2 Metadata: Evil or Genius? | Version 1 (US)","description":"Regular listeners to BBC Radio 4 may be familiar with the \u201cEvil Genius\u201d series, in which Russell Kane, assisted by a panel of expert and celebrity guests, One of our consultants here at Version 1 has explored EC2 metadata and explained what it is, what can we use it for and, is it evil or genius?","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.version1.com\/en-us\/ec2-metadata-evil-or-genius\/","og_locale":"en_US","og_type":"article","og_title":"EC2 Metadata: Evil or Genius? | Version 1 (US)","og_description":"Regular listeners to BBC Radio 4 may be familiar with the \u201cEvil Genius\u201d series, in which Russell Kane, assisted by a panel of expert and celebrity guests, One of our consultants here at Version 1 has explored EC2 metadata and explained what it is, what can we use it for and, is it evil or genius?","og_url":"https:\/\/www.version1.com\/en-us\/ec2-metadata-evil-or-genius\/","og_site_name":"Version 1 (US)","article_published_time":"2021-02-08T13:27:31+00:00","og_image":[{"width":680,"height":440,"url":"https:\/\/www.version1.com\/en-us\/wp-content\/uploads\/2021\/02\/laptop-user.jpg.webp","type":"image\/jpeg"}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.version1.com\/en-us\/ec2-metadata-evil-or-genius\/#article","isPartOf":{"@id":"https:\/\/www.version1.com\/en-us\/ec2-metadata-evil-or-genius\/"},"author":{"name":"","@id":""},"headline":"EC2 Metadata: Evil or Genius?","datePublished":"2021-02-08T13:27:31+00:00","mainEntityOfPage":{"@id":"https:\/\/www.version1.com\/en-us\/ec2-metadata-evil-or-genius\/"},"wordCount":1049,"publisher":{"@id":"https:\/\/www.version1.com\/en-us\/#organization"},"image":{"@id":"https:\/\/www.version1.com\/en-us\/ec2-metadata-evil-or-genius\/#primaryimage"},"thumbnailUrl":"https:\/\/www.version1.com\/en-us\/wp-content\/uploads\/2021\/02\/laptop-user.jpg.webp","keywords":["AWS"],"articleSection":["Blog"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.version1.com\/en-us\/ec2-metadata-evil-or-genius\/","url":"https:\/\/www.version1.com\/en-us\/ec2-metadata-evil-or-genius\/","name":"EC2 Metadata: Evil or Genius? | Version 1 (US)","isPartOf":{"@id":"https:\/\/www.version1.com\/en-us\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.version1.com\/en-us\/ec2-metadata-evil-or-genius\/#primaryimage"},"image":{"@id":"https:\/\/www.version1.com\/en-us\/ec2-metadata-evil-or-genius\/#primaryimage"},"thumbnailUrl":"https:\/\/www.version1.com\/en-us\/wp-content\/uploads\/2021\/02\/laptop-user.jpg.webp","datePublished":"2021-02-08T13:27:31+00:00","description":"Regular listeners to BBC Radio 4 may be familiar with the \u201cEvil Genius\u201d series, in which Russell Kane, assisted by a panel of expert and celebrity guests, One of our consultants here at Version 1 has explored EC2 metadata and explained what it is, what can we use it for and, is it evil or genius?","breadcrumb":{"@id":"https:\/\/www.version1.com\/en-us\/ec2-metadata-evil-or-genius\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.version1.com\/en-us\/ec2-metadata-evil-or-genius\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.version1.com\/en-us\/ec2-metadata-evil-or-genius\/#primaryimage","url":"https:\/\/www.version1.com\/en-us\/wp-content\/uploads\/2021\/02\/laptop-user.jpg.webp","contentUrl":"https:\/\/www.version1.com\/en-us\/wp-content\/uploads\/2021\/02\/laptop-user.jpg.webp","width":680,"height":440,"caption":"person sat at desk in front of laptop and monitor"},{"@type":"BreadcrumbList","@id":"https:\/\/www.version1.com\/en-us\/ec2-metadata-evil-or-genius\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.version1.com\/en-us\/"},{"@type":"ListItem","position":2,"name":"EC2 Metadata: Evil or Genius?"}]},{"@type":"WebSite","@id":"https:\/\/www.version1.com\/en-us\/#website","url":"https:\/\/www.version1.com\/en-us\/","name":"Version 1","description":"","publisher":{"@id":"https:\/\/www.version1.com\/en-us\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.version1.com\/en-us\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.version1.com\/en-us\/#organization","name":"Version 1","url":"https:\/\/www.version1.com\/en-us\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.version1.com\/en-us\/#\/schema\/logo\/image\/","url":"https:\/\/www.version1.com\/wp-content\/uploads\/2026\/05\/cropped-cropped-Favicon-2.png","contentUrl":"https:\/\/www.version1.com\/wp-content\/uploads\/2026\/05\/cropped-cropped-Favicon-2.png","width":512,"height":512,"caption":"Version 1"},"image":{"@id":"https:\/\/www.version1.com\/en-us\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/www.version1.com\/en-us\/wp-json\/wp\/v2\/posts\/7246","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.version1.com\/en-us\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.version1.com\/en-us\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/www.version1.com\/en-us\/wp-json\/wp\/v2\/comments?post=7246"}],"version-history":[{"count":0,"href":"https:\/\/www.version1.com\/en-us\/wp-json\/wp\/v2\/posts\/7246\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.version1.com\/en-us\/wp-json\/wp\/v2\/media\/7247"}],"wp:attachment":[{"href":"https:\/\/www.version1.com\/en-us\/wp-json\/wp\/v2\/media?parent=7246"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.version1.com\/en-us\/wp-json\/wp\/v2\/categories?post=7246"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.version1.com\/en-us\/wp-json\/wp\/v2\/tags?post=7246"},{"taxonomy":"industry","embeddable":true,"href":"https:\/\/www.version1.com\/en-us\/wp-json\/wp\/v2\/industry?post=7246"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}