<?xml version="1.0" encoding="UTF-8"?>
<RulePack xmlns="xmlns://www.fortifysoftware.com/schema/rules">
  <RulePackID>319687C3-9523-4647-95B4-3FBC435E1404</RulePackID>
  <SKU>Custom Android Rules</SKU>
  <Name>Custom Android Rules</Name>
  <Description><![CDATA[]]></Description>
  <Rules version="3.8">
    <RuleDefinitions>

      <!-- =============== Privacy Sensitive Sources ================= -->

      <!-- Doesn't work ... Just use Location.get(Latitude|Longitude)
      <DataflowEntryRule language="java" formatVersion="3.8">
	<RuleID>53D3CA8C-7AC5-4991-9B35-5D2B38072BB3</RuleID>
	<Notes>Location Info Source, callback from system API</Notes>
	<TaintFlags>+LOCATION</TaintFlags>
	<FunctionIdentifier>
	  <NamespaceName>
	    <Pattern>android\.location</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>LocationListener</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>onLocationChanged</Pattern>
	  </FunctionName>
	  <Parameters>
	    <ParamType>android.location.Location</ParamType>
	  </Parameters>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<InArguments>0</InArguments>
      </DataflowEntryRule>
      -->

      <DataflowSourceRule language="java" formatVersion="3.8">
	<RuleID>39C542E2-0464-4E37-8E3C-E06065AD4981</RuleID>
	<Notes>Taint source for Location</Notes>
	<TaintFlags>+LOCATION</TaintFlags>
	<FunctionIdentifier>
	  <NamespaceName>
	    <Pattern>android\.location</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Location</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>get(Latitude|Longitude)</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<OutArguments>return</OutArguments>
      </DataflowSourceRule>

      <DataflowSourceRule language="java" formatVersion="3.8">
	<RuleID>B24B904F-7B53-4C7F-A845-83F8B3871ADC</RuleID>
	<Notes>Taint source for IMEI</Notes>
	<TaintFlags>+IMEI</TaintFlags>
	<FunctionIdentifier>
	  <NamespaceName>
	    <Pattern>android\.telephony</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>TelephonyManager</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>getDeviceId</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<OutArguments>return</OutArguments>
      </DataflowSourceRule>
      
      <DataflowSourceRule language="java" formatVersion="3.8">
	<RuleID>252EE007-7F07-4E30-A20C-BF38D40E753E</RuleID>
	<Notes>Taint source for IMSI</Notes>
	<TaintFlags>+IMSI</TaintFlags>
	<FunctionIdentifier>
	  <NamespaceName>
	    <Pattern>android\.telephony</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>TelephonyManager</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>getSubscriberId</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<OutArguments>return</OutArguments>
      </DataflowSourceRule>
      
      <DataflowSourceRule language="java" formatVersion="3.8">
	<RuleID>324F14AE-57FA-453C-8548-4CC95D751EC6</RuleID>
	<Notes>Taint source for ICC_ID</Notes>
	<TaintFlags>+ICC_ID</TaintFlags>
	<FunctionIdentifier>
	  <NamespaceName>
	    <Pattern>android\.telephony</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>TelephonyManager</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>getSimSerialNumber</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<OutArguments>return</OutArguments>
      </DataflowSourceRule>
      
      <DataflowSourceRule language="java" formatVersion="3.8">
	<RuleID>53832DA3-AD51-4BE8-9E23-D5DC00CB6DA1</RuleID>
	<Notes>Taint source for Phone Number</Notes>
	<TaintFlags>+PH_NUM</TaintFlags>
	<FunctionIdentifier>
	  <NamespaceName>
	    <Pattern>android\.telephony</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>TelephonyManager</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>getLine1Number</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<OutArguments>return</OutArguments>
      </DataflowSourceRule>

      <!-- ============= Android Specific Passthrough ================ -->

      <!-- Using this as a taint source instead (see above)
      <DataflowPassthroughRule language="java" formatVersion="3.8">
	<RuleID>313632FC-0159-444E-8331-4873C9751411</RuleID>
	<Notes>Propatates the taint on a Location object to the elements</Notes>
	<FunctionIdentifier>
	  <NamespaceName>
	    <Pattern>android\.location</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Location</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>get(Latitude|Longitude)</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<InArguments>this</InArguments>
	<OutArguments>return</OutArguments>
      </DataflowPassthroughRule>
      -->
      
      <DataflowPassthroughRule language="java" formatVersion="3.8">
	<RuleID>3FC7F0CE-57BA-4CD9-83BB-3F66AD8CD2DD</RuleID>
	<Notes>Propatates the taint on a Handler message (may have lots of false positives)</Notes>
	<FunctionIdentifier>
	  <NamespaceName>
	    <Pattern>android\.os</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Handler</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>obtainMessage</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<InArguments>0...</InArguments>
	<OutArguments>return</OutArguments>
      </DataflowPassthroughRule>

      <DataflowPassthroughRule language="java" formatVersion="3.8">
	<RuleID>964BCC89-93BB-4E82-832A-495CB9866515</RuleID>
	<Notes>Propatates the taint on a Handler message (may have lots of false positives)</Notes>
	<FunctionIdentifier>
	  <NamespaceName>
	    <Pattern>android\.os</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Handler</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>sendMessage</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<InArguments>0</InArguments>
	<OutArguments>this</OutArguments>
      </DataflowPassthroughRule>

      <!-- ============= Additional Useful Passthrough =============== -->

      <!-- Fortify seems to include this already
      <DataflowPassthroughRule language="java" formatVersion="3.8">
	<RuleID>A56D67D4-1EAE-4290-86B6-BD085F864B6E</RuleID>
	<Notes>Propagates taint through the URL encoder (not Android specific)</Notes>
	<FunctionIdentifier>
	  <NamespaceName>
	    <Pattern>java\.net</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>URLEncoder</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>encode</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<InArguments>0</InArguments>
	<OutArguments>return</OutArguments>
      </DataflowPassthroughRule>
      -->

      <!-- ============= Identifying Network Traffic ================= -->

      <DataflowSourceRule language="java" formatVersion="3.8">
	<RuleID>8484CE94-F30A-4409-A531-9562549C2CDA</RuleID>
	<Notes>Identify an OutputStream for {Http}URLConnection</Notes>
	<FunctionIdentifier>
	  <NamespaceName>
	    <Pattern>java\.net</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>URLConnection</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>getOutputStream</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<OutArguments>return</OutArguments>
	<TaintFlags>+NETOUT</TaintFlags>
      </DataflowSourceRule>

      <DataflowSourceRule language="java" formatVersion="3.8">
	<RuleID>12DD8495-75A9-4100-969C-BC4054332D93</RuleID>
	<Notes>Identify an InputStream for {Http}URLConnection</Notes>
	<FunctionIdentifier>
	  <NamespaceName>
	    <Pattern>java\.net</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>URLConnection</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>getInputStream</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<OutArguments>return</OutArguments>
	<TaintFlags>+NETIN</TaintFlags>
      </DataflowSourceRule>

      <DataflowPassthroughRule language="java" formatVersion="3.8">
	<RuleID>02DFB1E0-9B86-4B14-9C91-06CC486D4AD2</RuleID>
	<Notes>Propagate taint marking for output streams and writers</Notes>
	<FunctionIdentifier>
	  <NamespaceName>
	    <Pattern>java\.io</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>(OutputStream|Writer)</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>init\^</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<InArguments>0</InArguments>
	<OutArguments>this</OutArguments>
      </DataflowPassthroughRule>

      <DataflowPassthroughRule language="java" formatVersion="3.8">
	<RuleID>B873E558-0950-4067-B2C0-3D1B17D606EE</RuleID>
	<Notes>Propagate taint marking for input streams and readers</Notes>
	<FunctionIdentifier>
	  <NamespaceName>
	    <Pattern>java\.io</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>(InputStream|Reader)</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>init\^</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<InArguments>0</InArguments>
	<OutArguments>this</OutArguments>
      </DataflowPassthroughRule>

      <DataflowPassthroughRule language="java" formatVersion="3.8">
	<RuleID>C415D7A7-CD02-4032-B79F-4B59C15FB2DC</RuleID>
	<Notes>Propagate taint marking to read information</Notes>
	<FunctionIdentifier>
	  <NamespaceName>
	    <Pattern>java\.io</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>(InputStream|Reader)</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>read</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<InArguments>this</InArguments>
	<OutArguments>0</OutArguments>
      </DataflowPassthroughRule>

      <DataflowSourceRule language="java" formatVersion="3.8">
	<RuleID>9A748FC4-3AEE-424A-AEC5-0493DF8E7412</RuleID>
	<Notes>Identify an input from HttpResponse</Notes>
	<FunctionIdentifier>
	  <NamespaceName>
	    <Pattern>org\.apache\.http</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>HttpResponse</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>getEntity</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<OutArguments>return</OutArguments>
	<TaintFlags>+NETIN</TaintFlags>
      </DataflowSourceRule>

      <DataflowPassthroughRule language="java" formatVersion="3.8">
	<RuleID>AF14B8FC-B929-404A-9972-9F32411F1C92</RuleID>
	<Notes>Propagate taint marking to information from HttpResponse entity</Notes>
	<FunctionIdentifier>
	  <NamespaceName>
	    <Pattern>org\.apache\.http\.util</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>EntityUtils</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>(toString|toByteArray|getContentCharSet)</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<InArguments>0</InArguments>
	<OutArguments>return</OutArguments>
      </DataflowPassthroughRule>

      <!-- ============= Identifying IPC Input ======================= -->

      <DataflowSourceRule language="java" formatVersion="3.8">
	<RuleID>E76ADE06-6AC1-4DCC-B2F9-05E5B6461BD0</RuleID>
	<Notes>Identify input from Intent Messages</Notes>
	<FunctionIdentifier>
	  <NamespaceName>
	    <Pattern>android\.content</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Intent</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>get.*</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<OutArguments>return</OutArguments>
	<TaintFlags>+IPCIN</TaintFlags>
      </DataflowSourceRule>

      <!-- =========================================================== -->
      <!-- =========== VULN: sensitive info to log file ============== -->
      <!-- =========================================================== -->

      <DataflowSinkRule language="java" formatVersion="3.8">
	<RuleID>8F598EA0-B0DD-46ED-9C79-39B47FE4CFC6</RuleID>
	<Notes>The log file is a dangerous place to write sensitive info</Notes>
	<VulnCategory>Android Secrecy</VulnCategory>
	<VulnSubcategory>Information Leak to Log (Location)</VulnSubcategory>
	<DefaultSeverity>5.0</DefaultSeverity>
	<Description>
	  <Abstract>
	  </Abstract>
	  <Explanation>
	  </Explanation>
	  <Recommendations>
	  </Recommendations>
	  <Tips>
	  </Tips>
	</Description>
	<Sink>
	  <InArguments>0...</InArguments>
	  <Conditional>
	    <TaintFlagSet taintFlag="LOCATION"/>
	  </Conditional>
	</Sink>
	<FunctionIdentifier>
	  <NamespaceName>
	    <Pattern>android\.util</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Log</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>.*</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
      </DataflowSinkRule>

      <DataflowSinkRule language="java" formatVersion="3.8">
	<RuleID>39121ABB-68BA-4FA9-88D8-ECFB5EAD8BA8</RuleID>
	<Notes>The log file is a dangerous place to write sensitive info</Notes>
	<VulnCategory>Android Secrecy</VulnCategory>
	<VulnSubcategory>Information Leak to Log (Phone Identifier)</VulnSubcategory>
	<DefaultSeverity>5.0</DefaultSeverity>
	<Description>
	  <Abstract>
	  </Abstract>
	  <Explanation>
	  </Explanation>
	  <Recommendations>
	  </Recommendations>
	  <Tips>
	  </Tips>
	</Description>
	<Sink>
	  <InArguments>0...</InArguments>
	  <Conditional>
	    <Or>
	      <TaintFlagSet taintFlag="IMEI" />
	      <TaintFlagSet taintFlag="IMSI" />
	      <TaintFlagSet taintFlag="ICC_ID" />
	      <TaintFlagSet taintFlag="PH_NUM" />
	    </Or>
	  </Conditional>
	</Sink>
	<FunctionIdentifier>
	  <NamespaceName>
	    <Pattern>android\.util</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Log</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>.*</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
      </DataflowSinkRule>

      <!-- =========================================================== -->
      <!-- =========== VULN: sensitive info to network =============== -->
      <!-- =========================================================== -->

      <DataflowSinkRule language="java" formatVersion="3.8">
	<RuleID>AB1CC8A6-9356-434F-AAA9-2C810EF1865A</RuleID>
	<Notes>Taint sink for OutputStream and friends</Notes>
	<VulnKingdom>Custom Android</VulnKingdom>
	<VulnCategory>Android Exfiltration</VulnCategory>
        <VulnSubcategory>Sensitive Info to Network - OutputStream (Location)</VulnSubcategory>
	<DefaultSeverity>5.0</DefaultSeverity>
	<Description>
	  <Abstract>
	  </Abstract>
	  <Explanation>
	  </Explanation>
	  <Recommendations>
	  </Recommendations>
	  <Tips>
	  </Tips>
	</Description>
	<Sink>
	  <InArguments>0</InArguments>
	  <Conditional>
	      <TaintFlagSet taintFlag="LOCATION"/>
	  </Conditional>
	</Sink>
	<Sink>
	  <InArguments>this</InArguments>
	  <Conditional>
	      <TaintFlagSet taintFlag="NETOUT"/>
	  </Conditional>
	</Sink>
	<FunctionIdentifier>
	  <NamespaceName>
	    <Pattern>java\.io</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>(OutputStream|Writer)</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>write</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
      </DataflowSinkRule>

      <DataflowSinkRule language="java" formatVersion="3.8">
	<RuleID>6BEDF9E8-6124-43DF-9A72-5DF137A78EB6</RuleID>
	<Notes>Taint sink for OutputStream and friends</Notes>
	<VulnKingdom>Custom Android</VulnKingdom>
	<VulnCategory>Android Exfiltration</VulnCategory>
        <VulnSubcategory>Sensitive Info to Network - OutputStream (Phone Info)</VulnSubcategory>
	<DefaultSeverity>5.0</DefaultSeverity>
	<Description>
	  <Abstract>
	  </Abstract>
	  <Explanation>
	  </Explanation>
	  <Recommendations>
	  </Recommendations>
	  <Tips>
	  </Tips>
	</Description>
	<Sink>
	  <InArguments>0</InArguments>
	  <Conditional>
	      <Or>
		<TaintFlagSet taintFlag="IMEI" />
		<TaintFlagSet taintFlag="IMSI" />
		<TaintFlagSet taintFlag="ICC_ID" />
		<TaintFlagSet taintFlag="PH_NUM" />
	      </Or>
	  </Conditional>
	</Sink>
	<Sink>
	  <InArguments>this</InArguments>
	  <Conditional>
	      <TaintFlagSet taintFlag="NETOUT"/>
	  </Conditional>
	</Sink>
	<FunctionIdentifier>
	  <NamespaceName>
	    <Pattern>java\.io</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>(OutputStream|Writer)</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>write</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
      </DataflowSinkRule>

      <DataflowSinkRule language="java" formatVersion="3.8">
	<RuleID>552E2188-CDC6-4569-8293-B0DD057A6698</RuleID>
	<Notes>Information leak to a URL</Notes>
	<VulnKingdom>Custom Android</VulnKingdom>
	<VulnCategory>Android Exfiltration</VulnCategory>
        <VulnSubcategory>Sensitive Info to Network - URL (Location)</VulnSubcategory>
	<DefaultSeverity>5.0</DefaultSeverity>
	<Description>
	  <Abstract>
	  </Abstract>
	  <Explanation>
	  </Explanation>
	  <Recommendations>
	  </Recommendations>
	  <Tips>
	  </Tips>
	</Description>
	<Sink>
	  <InArguments>0...</InArguments>
	  <Conditional>
	    <TaintFlagSet taintFlag="LOCATION"/>
	  </Conditional>
	</Sink>
	<FunctionIdentifier>
	  <NamespaceName>
	    <Pattern>java\.net</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>URL</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>(init\^|set)</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
      </DataflowSinkRule>

      <DataflowSinkRule language="java" formatVersion="3.8">
	<RuleID>934CC1C2-BA06-496D-81C5-0870AE52310A</RuleID>
	<Notes>Information leak to a URL</Notes>
	<VulnKingdom>Custom Android</VulnKingdom>
	<VulnCategory>Android Exfiltration</VulnCategory>
        <VulnSubcategory>Sensitive Info to Network - URL (Phone Info)</VulnSubcategory>
	<DefaultSeverity>5.0</DefaultSeverity>
	<Description>
	  <Abstract>
	  </Abstract>
	  <Explanation>
	  </Explanation>
	  <Recommendations>
	  </Recommendations>
	  <Tips>
	  </Tips>
	</Description>
	<Sink>
	  <InArguments>0...</InArguments>
	  <Conditional>
	    <Or>
	      <TaintFlagSet taintFlag="IMEI" />
	      <TaintFlagSet taintFlag="IMSI" />
	      <TaintFlagSet taintFlag="ICC_ID" />
	      <TaintFlagSet taintFlag="PH_NUM" />
	    </Or>
	  </Conditional>
	</Sink>
	<FunctionIdentifier>
	  <NamespaceName>
	    <Pattern>java\.net</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>URL</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>(init\^|set)</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
      </DataflowSinkRule>

      <!-- HttpPost uses the setEntity 
	   See: http://www.coderanch.com/t/471150/Android/Mobile/Post-data-Server
	   for example of using it with post parameters

	  TODO:
	   - Other ways to do this?
	   - propagate taint to NameValuePair? and then to List? and then to
	     UrlEncodedFormEntity?
       -->
      <DataflowSinkRule language="java" formatVersion="3.8">
	<RuleID>C339BA37-C662-4CD7-BA32-16C5336587F4</RuleID>
	<Notes>Information leak to HTTP Post parameter</Notes>
	<VulnKingdom>Custom Android</VulnKingdom>
	<VulnCategory>Android Exfiltration</VulnCategory>
        <VulnSubcategory>Sensitive Info to Network - HttpClient Param (Location)</VulnSubcategory>
	<DefaultSeverity>5.0</DefaultSeverity>
	<Description>
	  <Abstract>
	  </Abstract>
	  <Explanation>
	  </Explanation>
	  <Recommendations>
	  </Recommendations>
	  <Tips>
	  </Tips>
	</Description>
	<Sink>
	  <InArguments>0</InArguments>
	  <Conditional>
	    <TaintFlagSet taintFlag="LOCATION"/>
	  </Conditional>
	</Sink>
	<FunctionIdentifier>
	  <NamespaceName>
	    <Pattern>org\.apache\.http\.client\.methods</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>HttpEntityEnclosingRequestBase</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>setEntity</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
      </DataflowSinkRule>

      <DataflowSinkRule language="java" formatVersion="3.8">
	<RuleID>B530926F-5117-42F7-A6B7-0C2C6F24943C</RuleID>
	<Notes>Information leak to HTTP Post parameter</Notes>
	<VulnKingdom>Custom Android</VulnKingdom>
	<VulnCategory>Android Exfiltration</VulnCategory>
        <VulnSubcategory>Sensitive Info to Network - HttpClient Param (Phone Info)</VulnSubcategory>
	<DefaultSeverity>5.0</DefaultSeverity>
	<Description>
	  <Abstract>
	  </Abstract>
	  <Explanation>
	  </Explanation>
	  <Recommendations>
	  </Recommendations>
	  <Tips>
	  </Tips>
	</Description>
	<Sink>
	  <InArguments>0</InArguments>
	  <Conditional>
	    <Or>
	      <TaintFlagSet taintFlag="IMEI" />
	      <TaintFlagSet taintFlag="IMSI" />
	      <TaintFlagSet taintFlag="ICC_ID" />
	      <TaintFlagSet taintFlag="PH_NUM" />
	    </Or>
	  </Conditional>
	</Sink>
	<FunctionIdentifier>
	  <NamespaceName>
	    <Pattern>org\.apache\.http\.client\.methods</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>HttpEntityEnclosingRequestBase</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>setEntity</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
      </DataflowSinkRule>

      <!-- need these passthroughs for HttpClient Params -->
      <DataflowPassthroughRule language="java" formatVersion="3.8">
	<RuleID>8AECEDD6-DBB1-4B42-872F-FDFBE32D1D49</RuleID>
	<Notes>Propagate taint marking for BasicNameValuePair</Notes>
	<FunctionIdentifier>
	  <NamespaceName>
	    <Pattern>org\.apache\.http\.message</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>BasicNameValuePair</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>init\^</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<InArguments>0...</InArguments>
	<OutArguments>this</OutArguments>
      </DataflowPassthroughRule>

      <DataflowPassthroughRule language="java" formatVersion="3.8">
	<RuleID>181A68D5-D154-4E21-AB08-0FF2E34D3A47</RuleID>
	<Notes>Propagate taint marking for AbstractHttpEntity (e.g., URLEncodedFormEntity)</Notes>
	<FunctionIdentifier>
	  <NamespaceName>
	    <Pattern>org\.apache\.http\.entity</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>AbstractHttpEntity</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>init\^</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<InArguments>0...</InArguments>
	<OutArguments>this</OutArguments>
      </DataflowPassthroughRule>

      <!-- Not sure if this is needed as well. Is HttpEntity parent of AbstractHttpEntity? -->
      <DataflowPassthroughRule language="java" formatVersion="3.8">
	<RuleID>2C2AEE41-0F87-4C63-BE5E-CC2EA8445908</RuleID>
	<Notes>Propagate taint marking for HttpEntity (e.g., URLEncodedFormEntity)</Notes>
	<FunctionIdentifier>
	  <NamespaceName>
	    <Pattern>org\.apache\.http\.entity</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>HttpEntity</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>init\^</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<InArguments>0...</InArguments>
	<OutArguments>this</OutArguments>
      </DataflowPassthroughRule>

      <DataflowSinkRule language="java" formatVersion="3.8">
	<RuleID>82E82E70-6723-4BB3-A1C4-805689655A86</RuleID>
	<Notes>Information leak to HTTP property</Notes>
	<VulnKingdom>Custom Android</VulnKingdom>
	<VulnCategory>Android Exfiltration</VulnCategory>
        <VulnSubcategory>Sensitive Info to Network - HTTP Property (Location)</VulnSubcategory>
	<DefaultSeverity>5.0</DefaultSeverity>
	<Description>
	  <Abstract>
	  </Abstract>
	  <Explanation>
	  </Explanation>
	  <Recommendations>
	  </Recommendations>
	  <Tips>
	  </Tips>
	</Description>
	<Sink>
	  <InArguments>0,1</InArguments>
	  <Conditional>
	    <TaintFlagSet taintFlag="LOCATION"/>
	  </Conditional>
	</Sink>
	<FunctionIdentifier>
	  <NamespaceName>
	    <Pattern>java\.net</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>URLConnection</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>setRequestProperty</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
      </DataflowSinkRule>

      <DataflowSinkRule language="java" formatVersion="3.8">
	<RuleID>B13EFF2A-DC12-45B9-BA20-E929FB960582</RuleID>
	<Notes>Information leak to HTTP property</Notes>
	<VulnKingdom>Custom Android</VulnKingdom>
	<VulnCategory>Android Exfiltration</VulnCategory>
        <VulnSubcategory>Sensitive Info to Network - HTTP Property (Phone Info)</VulnSubcategory>
	<DefaultSeverity>5.0</DefaultSeverity>
	<Description>
	  <Abstract>
	  </Abstract>
	  <Explanation>
	  </Explanation>
	  <Recommendations>
	  </Recommendations>
	  <Tips>
	  </Tips>
	</Description>
	<Sink>
	  <InArguments>0,1</InArguments>
	  <Conditional>
	    <Or>
	      <TaintFlagSet taintFlag="IMEI" />
	      <TaintFlagSet taintFlag="IMSI" />
	      <TaintFlagSet taintFlag="ICC_ID" />
	      <TaintFlagSet taintFlag="PH_NUM" />
	    </Or>
	  </Conditional>
	</Sink>
	<FunctionIdentifier>
	  <NamespaceName>
	    <Pattern>java\.net</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>setRequestProperty</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>setEntity</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
      </DataflowSinkRule>

      <!-- =========================================================== -->
      <!-- =========== VULN: network info to Intent address ========== -->
      <!-- =========================================================== -->

      <DataflowPassthroughRule language="java" formatVersion="3.8">
	<RuleID>B5F33436-E2AC-4373-82FC-42B52099DC64</RuleID>
	<Notes>Propagates the NETIN flag from component string to ComponentName</Notes>
	<FunctionIdentifier>
	  <NamespaceName>
	    <Pattern>android\.content</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>ComponentName</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>init\^</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<InArguments>0...</InArguments>
	<OutArguments>this</OutArguments>
      </DataflowPassthroughRule>

      <DataflowSinkRule language="java" formatVersion="3.8">
	<RuleID>96D5FE90-2C13-47E0-A2AC-EA9706A97910</RuleID>
	<Notes>Network info to the Intent address</Notes>
	<VulnKingdom>Custom Android</VulnKingdom>
	<VulnCategory>Android Integrity</VulnCategory>
        <VulnSubcategory>Network to Intent Address (constructor)</VulnSubcategory>
	<DefaultSeverity>5.0</DefaultSeverity>
	<Description>
	  <Abstract>
	  </Abstract>
	  <Explanation>
	  </Explanation>
	  <Recommendations>
	  </Recommendations>
	  <Tips>
	  </Tips>
	</Description>
	<Sink>
	  <InArguments>0</InArguments>
	  <Conditional>
	    <TaintFlagSet taintFlag="NETIN" />
	  </Conditional>
	</Sink>
	<FunctionIdentifier>
	  <NamespaceName>
	    <Pattern>android\.content</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Intent</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>init\^</Pattern>
	  </FunctionName>
	  <Parameters>
	    <ParamType>java.lang.String</ParamType>
	    <WildCard min="0" max="3" />
	  </Parameters>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
      </DataflowSinkRule>

      <DataflowSinkRule language="java" formatVersion="3.8">
	<RuleID>01AD50BF-3D50-4A67-B9BA-094B0580CE29</RuleID>
	<Notes>Network info to the Intent address</Notes>
	<VulnKingdom>Custom Android</VulnKingdom>
	<VulnCategory>Android Integrity</VulnCategory>
        <VulnSubcategory>Network to Intent Address (setAction)</VulnSubcategory>
	<DefaultSeverity>5.0</DefaultSeverity>
	<Description>
	  <Abstract>
	  </Abstract>
	  <Explanation>
	  </Explanation>
	  <Recommendations>
	  </Recommendations>
	  <Tips>
	  </Tips>
	</Description>
	<Sink>
	  <InArguments>0</InArguments>
	  <Conditional>
	    <TaintFlagSet taintFlag="NETIN" />
	  </Conditional>
	</Sink>
	<FunctionIdentifier>
	  <NamespaceName>
	    <Pattern>android\.content</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Intent</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>setAction</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
      </DataflowSinkRule>

      <DataflowSinkRule language="java" formatVersion="3.8">
	<RuleID>BB0CB6F9-2697-48BA-A865-AB73656A67D2</RuleID>
	<Notes>Network info to the Intent address</Notes>
	<VulnKingdom>Custom Android</VulnKingdom>
	<VulnCategory>Android Integrity</VulnCategory>
        <VulnSubcategory>Network to Intent Address (setClassName|setComponent)</VulnSubcategory>
	<DefaultSeverity>5.0</DefaultSeverity>
	<Description>
	  <Abstract>
	  </Abstract>
	  <Explanation>
	  </Explanation>
	  <Recommendations>
	  </Recommendations>
	  <Tips>
	  </Tips>
	</Description>
	<Sink>
	  <InArguments>0...</InArguments>
	  <Conditional>
	    <TaintFlagSet taintFlag="NETIN" />
	  </Conditional>
	</Sink>
	<FunctionIdentifier>
	  <NamespaceName>
	    <Pattern>android\.content</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Intent</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>(setClassName|setComponent)</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
      </DataflowSinkRule>

      <!-- =========== VULN: IPC info to Intent Address ============== -->

      <DataflowSinkRule language="java" formatVersion="3.8">
	<RuleID>CCAE59C7-A564-417F-A597-FA8862ED2406</RuleID>
	<Notes>Network info to the Intent address</Notes>
	<VulnKingdom>Custom Android</VulnKingdom>
	<VulnCategory>Android Integrity</VulnCategory>
        <VulnSubcategory>IPC to Intent Address (constructor)</VulnSubcategory>
	<DefaultSeverity>5.0</DefaultSeverity>
	<Description>
	  <Abstract>
	  </Abstract>
	  <Explanation>
	  </Explanation>
	  <Recommendations>
	  </Recommendations>
	  <Tips>
	  </Tips>
	</Description>
	<Sink>
	  <InArguments>0</InArguments>
	  <Conditional>
	    <TaintFlagSet taintFlag="IPCIN" />
	  </Conditional>
	</Sink>
	<FunctionIdentifier>
	  <NamespaceName>
	    <Pattern>android\.content</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Intent</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>init\^</Pattern>
	  </FunctionName>
	  <Parameters>
	    <ParamType>java.lang.String</ParamType>
	    <WildCard min="0" max="3" />
	  </Parameters>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
      </DataflowSinkRule>

      <DataflowSinkRule language="java" formatVersion="3.8">
	<RuleID>7EFD9748-D329-4429-9FEC-FA2E940E6698</RuleID>
	<Notes>Network info to the Intent address</Notes>
	<VulnKingdom>Custom Android</VulnKingdom>
	<VulnCategory>Android Integrity</VulnCategory>
        <VulnSubcategory>IPC to Intent Address (setAction)</VulnSubcategory>
	<DefaultSeverity>5.0</DefaultSeverity>
	<Description>
	  <Abstract>
	  </Abstract>
	  <Explanation>
	  </Explanation>
	  <Recommendations>
	  </Recommendations>
	  <Tips>
	  </Tips>
	</Description>
	<Sink>
	  <InArguments>0</InArguments>
	  <Conditional>
	    <TaintFlagSet taintFlag="IPCIN" />
	  </Conditional>
	</Sink>
	<FunctionIdentifier>
	  <NamespaceName>
	    <Pattern>android\.content</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Intent</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>setAction</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
      </DataflowSinkRule>

      <DataflowSinkRule language="java" formatVersion="3.8">
	<RuleID>B3E8086D-0700-40EF-AA91-7C7440BCB516</RuleID>
	<Notes>Network info to the Intent address</Notes>
	<VulnKingdom>Custom Android</VulnKingdom>
	<VulnCategory>Android Integrity</VulnCategory>
        <VulnSubcategory>IPC to Intent Address (setClassName|setComponent)</VulnSubcategory>
	<DefaultSeverity>5.0</DefaultSeverity>
	<Description>
	  <Abstract>
	  </Abstract>
	  <Explanation>
	  </Explanation>
	  <Recommendations>
	  </Recommendations>
	  <Tips>
	  </Tips>
	</Description>
	<Sink>
	  <InArguments>0...</InArguments>
	  <Conditional>
	    <TaintFlagSet taintFlag="IPCIN" />
	  </Conditional>
	</Sink>
	<FunctionIdentifier>
	  <NamespaceName>
	    <Pattern>android\.content</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Intent</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>(setClassName|setComponent)</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
      </DataflowSinkRule>

      <!-- =========================================================== -->
      <!-- =========== VULN: Unprotected Intent Broadcast ============ -->
      <!-- =========================================================== -->

      <ControlflowRule formatVersion="3.8" language="java">
	<RuleID>36B9101F-E8F3-458E-95A9-02041A0FBC76</RuleID>
	<Notes>Looks for unprotected, public intent broadcats</Notes>
	<VulnKingdom>Custom Android</VulnKingdom>
	<VulnCategory>Android Secrecy</VulnCategory>
        <VulnSubcategory>Unprotected Intent Broadcast</VulnSubcategory>
	<DefaultSeverity>5.0</DefaultSeverity>
	<Description>
	  <Abstract>
	  </Abstract>
	  <Explanation>
	  </Explanation>
	  <Recommendations>
	  </Recommendations>
	  <Tips>
	  </Tips>
	</Description>
	<FunctionIdentifier id="new">
	  <NamespaceName>
	    <Pattern>android\.content</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Intent</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>init\^</Pattern>
	  </FunctionName>
	  <Parameters>
	    <WildCard min="0" max="0" />
	  </Parameters>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<FunctionIdentifier id="new_dup">
	  <NamespaceName>
	    <Pattern>android\.content</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Intent</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>init\^</Pattern>
	  </FunctionName>
	  <Parameters>
	    <ParamType>android.content.Intent</ParamType>
	  </Parameters>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<FunctionIdentifier id="new_action">
	  <NamespaceName>
	    <Pattern>android\.content</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Intent</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>init\^</Pattern>
	  </FunctionName>
	  <Parameters>
	    <ParamType>java.lang.string</ParamType>
	    <WildCard min="0" max="3" />
	  </Parameters>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<FunctionIdentifier id="new_class">
	  <NamespaceName>
	    <Pattern>android\.content</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Intent</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>init\^</Pattern>
	  </FunctionName>
	  <Parameters>
	    <ParamType>android.content.Context</ParamType>
	    <ParamType>java.lang.Class</ParamType>
	  </Parameters>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<FunctionIdentifier id="set_class">
	  <NamespaceName>
	    <Pattern>android\.content</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Intent</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>setClass.*</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<FunctionIdentifier id="set_component">
	  <NamespaceName>
	    <Pattern>android\.content</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Intent</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>setComponent</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<FunctionIdentifier id="put_extra">
	  <NamespaceName>
	    <Pattern>android\.content</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Intent</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>putExtra</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<FunctionIdentifier id="unprotected_bcast">
	  <NamespaceName>
	    <Pattern>android\.content</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Context</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>sendBroadcast</Pattern>
	  </FunctionName>
	  <Parameters>
	    <ParamType>android.content.Intent</ParamType>
	  </Parameters>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<FunctionIdentifier id="protected_bcast">
	  <NamespaceName>
	    <Pattern>android\.content</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Context</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>sendBroadcast</Pattern>
	  </FunctionName>
	  <Parameters>
	    <ParamType>android.content.Intent</ParamType>
	    <ParamType>java.lang.String</ParamType>
	  </Parameters>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>

	<Definition>
	  <![CDATA[
	  state start (start);
	  state empty;
	  state specified;
	  state has_data;
	  state unsafe (error);
	  var i;

	  start -> specified { i.$new_class(...) }
	  start -> empty { i.$new(...) | i.$new_action(...) }
	  empty -> specified { i.$set_class(...) | i.$set_component(...)}
	  empty -> has_data { i.$put_extra(...) }
	  has_data -> specified { i.$set_class(...) | i.$set_component(...)}
	  has_data -> unsafe { $unprotected_bcast(i) | $protected_bcast(i, null) }
	  ]]>
	</Definition>

      </ControlflowRule>
  
      <!-- =========================================================== -->
      <!-- =========== MAL: Background Video ========================= -->
      <!-- =========================================================== -->

      <ControlflowRule formatVersion="3.8" language="java">
	<RuleID>F8D2775A-106E-4827-9285-3856EF1E1768</RuleID>
	<Notes>Ensures that setPreviewDisplay is used whenever a video source is used</Notes>
	<VulnKingdom>Custom Android</VulnKingdom>
	<VulnCategory>Android Exfiltration</VulnCategory>
        <VulnSubcategory>Background Video</VulnSubcategory>
	<DefaultSeverity>5.0</DefaultSeverity>
	<Description>
	  <Abstract>
	  </Abstract>
	  <Explanation>
	    Starts video recording without calling setPreviewDisplay()
	  </Explanation>
	  <Recommendations>
	  </Recommendations>
	  <Tips>
	  </Tips>
	</Description>
	<FunctionIdentifier id="new">
	  <NamespaceName>
	    <Pattern>android\.media</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>MediaRecorder</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>init\^</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<FunctionIdentifier id="setVideo">
	  <NamespaceName>
	    <Pattern>android\.media</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>MediaRecorder</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>setVideoSource</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<FunctionIdentifier id="setPreview">
	  <NamespaceName>
	    <Pattern>android\.media</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>MediaRecorder</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>setPreviewDisplay</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<FunctionIdentifier id="start">
	  <NamespaceName>
	    <Pattern>android\.media</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>MediaRecorder</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>start</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<!-- Note: According to:
	     http://developer.android.com/reference/android/hardware/Camera.html
	     The camera API cannot call takePicture() unless startPreview()
	     is called, and startPreview() cannot be called unless
	     setPreviewDisplay() is called. Therefore, simple picture taking without 
	     the user's knowledge should not be possible. Needs to record it as video.
	 -->
<!-- FIXME: for some reason, if set_preview is called before set_video, it is
     still an error. but if set_video is first, the report goes away. -->
	 <Definition>
	   <![CDATA[
	   state start (start);
	   state alloc;
	   state video;
	   state preview;
	   state video_preview;
	   state unsafe_start (error);
	   var r;

	   start -> alloc { r.new(...) }
	   alloc -> preview { r.$setPreview(...) }
	   alloc -> video { r.$setVideo(...) }
	   video -> video_preview { r.$setPreview(...) }
	   preview -> video_preview { r.$setVideo(...) }
	   video -> unsafe_start { r.$start(...) }
	   ]]>
	 </Definition>
       </ControlflowRule>

      <!-- =========================================================== -->
      <!-- =========== MAL: Background Audio/Video =================== -->
      <!-- =========================================================== -->

      <StructuralRule formatVersion="3.8" language = "java">
	<RuleID>6F30A869-45C6-448D-8419-9C28C2A22197</RuleID>
	<Notes>Use of microphone without path from an Activity</Notes>
	<VulnKingdom>Custom Android</VulnKingdom>
	<VulnCategory>Android Exfiltration</VulnCategory>
        <VulnSubcategory>Background Audio (AudioRecord)</VulnSubcategory>
	<DefaultSeverity>5.0</DefaultSeverity>
	<Description>
	  <Abstract>
	  </Abstract>
	  <Explanation>
	    No path from Activity to call to AudioRecord.read()
	  </Explanation>
	  <Recommendations>
	  </Recommendations>
	  <Tips>
	  </Tips>
	</Description>
	<Predicate>
	  <![CDATA[
	  FunctionCall c: c.function.name == "read" and
	  c.function.enclosingClass.name == "android.media.AudioRecord"
	  and not c.enclosingClass reachedBy
	  [ Class a: a.supers contains
	  [ Class super: super.name == "android.app.Activity"]]	
	  ]]>
	</Predicate>
      </StructuralRule>

      <StructuralRule formatVersion="3.8" language = "java">
	<RuleID>5FC87571-E78F-4A41-9CD4-E391A39BB64F</RuleID>
	<Notes>Use of microphone or camera without path from an Activity</Notes>
	<VulnKingdom>Custom Android</VulnKingdom>
	<VulnCategory>Android Exfiltration</VulnCategory>
	<VulnSubcategory>Background Audio/Video (MediaRecorder)</VulnSubcategory>
	<DefaultSeverity>5.0</DefaultSeverity>
	<Description>
	  <Abstract>
	  </Abstract>
	  <Explanation>
	    No path from Activity to call to MediaRecorder.start()
	  </Explanation>
	  <Recommendations>
	  </Recommendations>
	  <Tips>
	  </Tips>
	</Description>
	<Predicate>
	  <![CDATA[
	  FunctionCall c: c.function.name == "start" and
	  c.function.enclosingClass.name == "android.media.MediaRecorder"
	  and not c.enclosingClass reachedBy
	  [ Class a: a.supers contains
	  [ Class super: super.name == "android.app.Activity"]]	
	  ]]>
	</Predicate>
      </StructuralRule>

      <!-- =========================================================== -->
      <!-- =========== VULN: No IPC Null Check ======================= -->
      <!-- =========================================================== -->

      <ControlflowRule formatVersion="3.8" language="java">
	<RuleID>A53F5A3D-C8C7-40E8-92F8-1A9F85C0F47C</RuleID>
	<Notes>Null check for IPC in component</Notes>
	<VulnKingdom>Custom Android</VulnKingdom>
	<VulnCategory>Android Availability</VulnCategory>
        <VulnSubcategory>IPC Null Check</VulnSubcategory>
	<DefaultSeverity>5.0</DefaultSeverity>
	<Description>
	  <Abstract>
	  </Abstract>
	  <Explanation>
	  </Explanation>
	  <Recommendations>
	  </Recommendations>
	  <Tips>
	  </Tips>
	</Description>
	<FunctionIdentifier id="getAction">
	  <NamespaceName>
	    <Pattern>android\.content</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Intent</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>getAction</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<FunctionIdentifier id="getExtra">
	  <NamespaceName>
	    <Pattern>android\.content</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Intent</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>get.*Extra(s)?</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<FunctionIdentifier id="bget">
	  <NamespaceName>
	    <Pattern>android\.os</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Bundle</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>get.*</Pattern>
	  </FunctionName>
	  <Parameters>
	    <!-- the two parameter version has a default value and is safe -->
	    <ParamType>java.lang.String</ParamType>
	  </Parameters>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<FunctionIdentifier id="any">
	  <NamespaceName>
	    <Pattern>.*</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>.*</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>.*</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true"/>
	</FunctionIdentifier>
	<Definition>
	  <![CDATA[
	  state start (start);
	  state accessed;
	  state checked;
	  state used (error);
	  var i;

	  start -> accessed { i = $getAction(...) | i = $getExtra(...) | i = $bget(...) }
	  accessed -> checked { #compare(i, null) }
	  accessed -> used { i.$any(...) }
	  ]]>
	</Definition>
      </ControlflowRule>

      <ControlflowRule formatVersion="3.8" language="java">
	<RuleID>69DEA227-49C8-4C61-B028-6B4825D8F763</RuleID>
	<Notes>Null check for IPC in component</Notes>
	<VulnKingdom>Custom Android</VulnKingdom>
	<VulnCategory>Android Availability</VulnCategory>
        <VulnSubcategory>IPC Null Check (Service)</VulnSubcategory>
	<DefaultSeverity>5.0</DefaultSeverity>
	<Description>
	  <Abstract>
	  </Abstract>
	  <Explanation>
	  </Explanation>
	  <Recommendations>
	  </Recommendations>
	  <Tips>
	  </Tips>
	</Description>
	<Limit>
	  <FunctionIdentifier>
	    <NamespaceName>
	      <Pattern>android\.app</Pattern>
	    </NamespaceName>
	    <ClassName>
	      <Pattern>Service</Pattern>
	    </ClassName>
	    <FunctionName>
	      <Pattern>.*</Pattern>
	    </FunctionName>
	    <ApplyTo implements="true" overrides="true" extends="true" />
	  </FunctionIdentifier>
	</Limit>
	<FunctionIdentifier id="getAction">
	  <NamespaceName>
	    <Pattern>android\.content</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Intent</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>getAction</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<FunctionIdentifier id="getExtra">
	  <NamespaceName>
	    <Pattern>android\.content</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Intent</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>get.*Extra(s)?</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<FunctionIdentifier id="bget">
	  <NamespaceName>
	    <Pattern>android\.os</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Bundle</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>get.*</Pattern>
	  </FunctionName>
	  <Parameters>
	    <!-- the two parameter version has a default value and is safe -->
	    <ParamType>java.lang.String</ParamType>
	  </Parameters>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<FunctionIdentifier id="any">
	  <NamespaceName>
	    <Pattern>.*</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>.*</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>.*</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true"/>
	</FunctionIdentifier>
	<Definition>
	  <![CDATA[
	  state start (start);
	  state accessed;
	  state checked;
	  state used (error);
	  var i;

	  start -> accessed { i = $getAction(...) | i = $getExtra(...) | i = $bget(...) }
	  accessed -> checked { #compare(i, null) }
	  accessed -> used { i.$any(...) }
	  ]]>
	</Definition>
      </ControlflowRule>

      <ControlflowRule formatVersion="3.8" language="java">
	<RuleID>AA7286F5-BC28-47A3-B927-BB6AE7A1724A</RuleID>
	<Notes>Null check for IPC in component</Notes>
	<VulnKingdom>Custom Android</VulnKingdom>
	<VulnCategory>Android Availability</VulnCategory>
        <VulnSubcategory>IPC Null Check (Receiver)</VulnSubcategory>
	<DefaultSeverity>5.0</DefaultSeverity>
	<Description>
	  <Abstract>
	  </Abstract>
	  <Explanation>
	  </Explanation>
	  <Recommendations>
	  </Recommendations>
	  <Tips>
	  </Tips>
	</Description>
	<Limit>
	  <FunctionIdentifier>
	    <NamespaceName>
	      <Pattern>android\.content</Pattern>
	    </NamespaceName>
	    <ClassName>
	      <Pattern>BroadcastReceiver</Pattern>
	    </ClassName>
	    <FunctionName>
	      <Pattern>.*</Pattern>
	    </FunctionName>
	    <ApplyTo implements="true" overrides="true" extends="true" />
	  </FunctionIdentifier>
	</Limit>
	<FunctionIdentifier id="getAction">
	  <NamespaceName>
	    <Pattern>android\.content</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Intent</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>getAction</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<FunctionIdentifier id="getExtra">
	  <NamespaceName>
	    <Pattern>android\.content</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Intent</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>get.*Extra(s)?</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<FunctionIdentifier id="bget">
	  <NamespaceName>
	    <Pattern>android\.os</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Bundle</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>get.*</Pattern>
	  </FunctionName>
	  <Parameters>
	    <!-- the two parameter version has a default value and is safe -->
	    <ParamType>java.lang.String</ParamType>
	  </Parameters>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<FunctionIdentifier id="any">
	  <NamespaceName>
	    <Pattern>.*</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>.*</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>.*</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true"/>
	</FunctionIdentifier>
	<Definition>
	  <![CDATA[
	  state start (start);
	  state accessed;
	  state checked;
	  state used (error);
	  var i;

	  start -> accessed { i = $getAction(...) | i = $getExtra(...) | i = $bget(...) }
	  accessed -> checked { #compare(i, null) }
	  accessed -> used { i.$any(...) }
	  ]]>
	</Definition>
      </ControlflowRule>

      <ControlflowRule formatVersion="3.8" language="java">
	<RuleID>B0060613-012C-4AC5-9205-E0E6469E503E</RuleID>
	<Notes>Null check for IPC in component</Notes>
	<VulnKingdom>Custom Android</VulnKingdom>
	<VulnCategory>Android Availability</VulnCategory>
        <VulnSubcategory>IPC Null Check (Activity)</VulnSubcategory>
	<DefaultSeverity>5.0</DefaultSeverity>
	<Description>
	  <Abstract>
	  </Abstract>
	  <Explanation>
	  </Explanation>
	  <Recommendations>
	  </Recommendations>
	  <Tips>
	  </Tips>
	</Description>
	<Limit>
	  <FunctionIdentifier>
	    <NamespaceName>
	      <Pattern>android\.app</Pattern>
	    </NamespaceName>
	    <ClassName>
	      <Pattern>Activity</Pattern>
	    </ClassName>
	    <FunctionName>
	      <Pattern>.*</Pattern>
	    </FunctionName>
	    <ApplyTo implements="true" overrides="true" extends="true" />
	  </FunctionIdentifier>
	</Limit>
	<FunctionIdentifier id="getAction">
	  <NamespaceName>
	    <Pattern>android\.content</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Intent</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>getAction</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<FunctionIdentifier id="getExtra">
	  <NamespaceName>
	    <Pattern>android\.content</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Intent</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>get.*Extra(s)?</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<FunctionIdentifier id="bget">
	  <NamespaceName>
	    <Pattern>android\.os</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Bundle</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>get.*</Pattern>
	  </FunctionName>
	  <Parameters>
	    <!-- the two parameter version has a default value and is safe -->
	    <ParamType>java.lang.String</ParamType>
	  </Parameters>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<FunctionIdentifier id="any">
	  <NamespaceName>
	    <Pattern>.*</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>.*</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>.*</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true"/>
	</FunctionIdentifier>
	<Definition>
	  <![CDATA[
	  state start (start);
	  state accessed;
	  state checked;
	  state used (error);
	  var i;

	  start -> accessed { i = $getAction(...) | i = $getExtra(...) | i = $bget(...) }
	  accessed -> checked { #compare(i, null) }
	  accessed -> used { i.$any(...) }
	  ]]>
	</Definition>
      </ControlflowRule>

      <!-- =========================================================== -->
      <!-- =========== VULN: Unsafe Pending Intent =================== -->
      <!-- =========================================================== -->

      <ControlflowRule formatVersion="3.8" language="java">
	<RuleID>0C393891-7902-4E38-AB02-204EAA1C0D04</RuleID>
	<VulnKingdom>Custom Android</VulnKingdom>
	<VulnCategory>Android Integrity</VulnCategory>
        <VulnSubcategory>Unsafe Pending Intent</VulnSubcategory>
	<DefaultSeverity>5.0</DefaultSeverity>
	<Description>
	  <Abstract>
	  </Abstract>
	  <Explanation>
	    PendingIntent objects should only be created from Intents with the
	    destination component class name specified explicitly.
	  </Explanation>
	  <Recommendations>
	  </Recommendations>
	  <Tips>
	  </Tips>
	</Description>
	<FunctionIdentifier id="new">
	  <NamespaceName>
	    <Pattern>android\.content</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Intent</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>init\^</Pattern>
	  </FunctionName>
	  <Parameters>
	    <WildCard min="0" max="0" />
	  </Parameters>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<FunctionIdentifier id="new_dup">
	  <NamespaceName>
	    <Pattern>android\.content</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Intent</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>init\^</Pattern>
	  </FunctionName>
	  <Parameters>
	    <ParamType>android.content.Intent</ParamType>
	  </Parameters>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<FunctionIdentifier id="new_action">
	  <NamespaceName>
	    <Pattern>android\.content</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Intent</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>init\^</Pattern>
	  </FunctionName>
	  <Parameters>
	    <ParamType>java.lang.string</ParamType>
	    <WildCard min="0" max="3" />
	  </Parameters>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<FunctionIdentifier id="new_class">
	  <NamespaceName>
	    <Pattern>android\.content</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Intent</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>init\^</Pattern>
	  </FunctionName>
	  <Parameters>
	    <ParamType>android.content.Context</ParamType>
	    <ParamType>java.lang.Class</ParamType>
	  </Parameters>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<FunctionIdentifier id="set_class">
	  <NamespaceName>
	    <Pattern>android\.content</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Intent</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>setClass.*</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<FunctionIdentifier id="set_component">
	  <NamespaceName>
	    <Pattern>android\.content</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Intent</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>setComponent</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<FunctionIdentifier id="getp">
	  <NamespaceName>
	    <Pattern>android\.app</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>PendingIntent</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>get(Activity|Broadcast|Service)</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>

	<Definition>
	  <![CDATA[
	  state start (start);
	  state empty;
	  state specified;
	  state unsafe (error);
	  var i;

	  start -> specified { i.$new_class(...) }
	  start -> empty { i.$new(...) | i.$new_action(...) }
	  empty -> specified { i.$set_class(...) | i.$set_component(...)}
	  empty -> unsafe { $getp(?, ?, i, ?) }
	  ]]>
	</Definition>
      
      </ControlflowRule>

      <ControlflowRule formatVersion="3.8" language="java">
	<RuleID>A50DCA3D-9D7B-47E4-BCE0-A189BC4A2973</RuleID>
	<VulnKingdom>Custom Android</VulnKingdom>
	<VulnCategory>Android Integrity</VulnCategory>
        <VulnSubcategory>Unsafe Pending Intent (RemoteView, so okay?)</VulnSubcategory>
	<DefaultSeverity>5.0</DefaultSeverity>
	<Description>
	  <Abstract>
	  </Abstract>
	  <Explanation>
	    PendingIntent objects should only be created from Intents with the
	    destination component class name specified explicitly.
	  </Explanation>
	  <Recommendations>
	  </Recommendations>
	  <Tips>
	  </Tips>
	</Description>
	<FunctionIdentifier id="new">
	  <NamespaceName>
	    <Pattern>android\.content</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Intent</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>init\^</Pattern>
	  </FunctionName>
	  <Parameters>
	    <WildCard min="0" max="0" />
	  </Parameters>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<FunctionIdentifier id="new_dup">
	  <NamespaceName>
	    <Pattern>android\.content</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Intent</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>init\^</Pattern>
	  </FunctionName>
	  <Parameters>
	    <ParamType>android.content.Intent</ParamType>
	  </Parameters>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<FunctionIdentifier id="new_action">
	  <NamespaceName>
	    <Pattern>android\.content</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Intent</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>init\^</Pattern>
	  </FunctionName>
	  <Parameters>
	    <ParamType>java.lang.string</ParamType>
	    <WildCard min="0" max="3" />
	  </Parameters>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<FunctionIdentifier id="new_class">
	  <NamespaceName>
	    <Pattern>android\.content</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Intent</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>init\^</Pattern>
	  </FunctionName>
	  <Parameters>
	    <ParamType>android.content.Context</ParamType>
	    <ParamType>java.lang.Class</ParamType>
	  </Parameters>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<FunctionIdentifier id="set_class">
	  <NamespaceName>
	    <Pattern>android\.content</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Intent</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>setClass.*</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<FunctionIdentifier id="set_component">
	  <NamespaceName>
	    <Pattern>android\.content</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Intent</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>setComponent</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<FunctionIdentifier id="getp">
	  <NamespaceName>
	    <Pattern>android\.app</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>PendingIntent</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>get(Activity|Broadcast|Service)</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<FunctionIdentifier id="onClick">
	  <NamespaceName>
	    <Pattern>android\.widget</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>RemoteViews</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>setOnClickPendingIntent</Pattern>
	  </FunctionName>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>

	<Definition>
	  <![CDATA[
	  state start (start);
	  state empty;
	  state specified;
	  state unsafe;
	  state onclick (error);
	  var i;
	  var p;

	  start -> specified { i.$new_class(...) }
	  start -> empty { i.$new(...) | i.$new_action(...) }
	  empty -> specified { i.$set_class(...) | i.$set_component(...)}
	  empty -> unsafe { p = $getp(?, ?, i, ?) }
	  unsafe -> onclick { $onClick(?, p) }
	  ]]>
	</Definition>
      
      </ControlflowRule>
 
      <!-- =========================================================== -->
      <!-- =========== VULN: Unprotected Broadcast Receiver ========== -->
      <!-- =========================================================== -->

      <ControlflowRule formatVersion="3.8" language="java">
	<RuleID>AC882B23-4161-4CC3-9638-92D7F71A9669</RuleID>
	<Notes>Look for unprotected public dynamic broadcast recievers</Notes>
	<VulnKingdom>Custom Android</VulnKingdom>
	<VulnCategory>Android Integrity</VulnCategory>
        <VulnSubcategory>Unprotected Broadcast Receiver</VulnSubcategory>
	<DefaultSeverity>5.0</DefaultSeverity>
	<Description>
	  <Abstract>
	  </Abstract>
	  <Explanation>
	    Only protected broadcast receivers should specify an IntentFilter
	    that contains anction string subscriptions.
	  </Explanation>
	  <Recommendations>
	  </Recommendations>
	  <Tips>
	  </Tips>
	</Description>
	<FunctionIdentifier id="unprotectedReg">
	  <NamespaceName>
	    <Pattern>android\.content</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Context</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>registerReceiver</Pattern>
	  </FunctionName>
	  <Parameters>
	    <ParamType>android.content.BroadcastReceiver</ParamType>
	    <ParamType>android.content.IntentFilter</ParamType>
	  </Parameters>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<FunctionIdentifier id="protectedReg">
	  <NamespaceName>
	    <Pattern>android\.content</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Context</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>registerReceiver</Pattern>
	  </FunctionName>
	  <Parameters>
	    <ParamType>android.content.BroadcastReceiver</ParamType>
	    <ParamType>android.content.IntentFilter</ParamType>
	    <ParamType>java.lang.String</ParamType>
	    <ParamType>android.os.Handler</ParamType>
	  </Parameters>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<FunctionIdentifier id="newIF">
	  <NamespaceName>
	    <Pattern>android\.content</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>IntentFilter</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>init\^</Pattern>
	  </FunctionName>
	  <Parameters>
	    <WildCard min="0" max="0" />
	  </Parameters>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<FunctionIdentifier id="newIF_public">
	  <NamespaceName>
	    <Pattern>android\.content</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>IntentFilter</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>init\^</Pattern>
	  </FunctionName>
	  <Parameters>
	    <ParamType>java.lang.String</ParamType>
	    <WildCard min="0" max="1" />
	  </Parameters>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<FunctionIdentifier id="newIF_dup">
	  <NamespaceName>
	    <Pattern>android\.content</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>IntentFilter</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>init\^</Pattern>
	  </FunctionName>
	  <Parameters>
	    <ParamType>android.content.IntentFilter</ParamType>
	  </Parameters>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>
	<FunctionIdentifier id="addIF_action">
	  <NamespaceName>
	    <Pattern>android\.content</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>IntentFilter</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>addAction</Pattern>
	  </FunctionName>
	  <Parameters>
	    <ParamType>java.lang.String</ParamType>
	  </Parameters>
	  <ApplyTo implements="true" overrides="true" extends="true" />
	</FunctionIdentifier>

	<Definition>
	  <![CDATA[
	  state start (start);
	  state empty_if;
	  state public;
	  state unprotected (error);
	  var if;

	  start -> public { if.$newIF_public(...) }
	  start -> empty_if { if.$newIF(...) }
	  empty_if -> public { if.$addIF_action(...) }
	  public -> unprotected { $unprotectedReg(?, if) | $protectedReg(?, if, null, ?) }
	  ]]>
	</Definition>

      </ControlflowRule>

      <!-- =========================================================== -->
      <!-- =========== MAL: Static SMS destinagtion ================== -->
      <!-- =========================================================== -->

      <SemanticRule language="java" formatVersion="3.8">
	<RuleID>3C8446E0-BC96-42D3-A6FD-F867AFC97599</RuleID>
	<Notes>Finds static parameters to SMS send call</Notes>
	<VulnKingdom>Custom Android</VulnKingdom>
	<VulnCategory>Android Service Abuse</VulnCategory>
        <VulnSubcategory>Constant Phone Number for SMS</VulnSubcategory>
	<DefaultSeverity>5.0</DefaultSeverity>
	<Description>
	  <Abstract>
	  </Abstract>
	  <Explanation>
	  </Explanation>
	  <Recommendations>
	  </Recommendations>
	  <Tips>
	  </Tips>
	</Description>
	<Type>default</Type>
	<FunctionIdentifier>
	  <NamespaceName>
	    <Pattern>android\.telephony</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>SmsManager</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>(sendTextMessage|sendDataMessage|sendMultipartTextMessage)</Pattern>
	  </FunctionName>
	</FunctionIdentifier>
	<Conditional>
	  <IsConstant argument="0" />
	</Conditional>
      </SemanticRule>

      <!-- =========================================================== -->
      <!-- =========== MAL: Hardcoded Phone Number  ================== -->
      <!-- =========================================================== -->

      <SemanticRule language="java" formatVersion="3.8">
	<RuleID>952B14B7-C6AA-4945-AEE2-1572EED9E768</RuleID>
	<Notes>Finds hardcode phone numbers format: tel:123456789</Notes>
	<VulnKingdom>Custom Android</VulnKingdom>
	<VulnCategory>Android Service Abuse</VulnCategory>
        <VulnSubcategory>Hardcoded Phone Number</VulnSubcategory>
	<DefaultSeverity>5.0</DefaultSeverity>
	<Description>
	  <Abstract>
	  </Abstract>
	  <Explanation>
	  </Explanation>
	  <Recommendations>
	  </Recommendations>
	  <Tips>
	  </Tips>
	</Description>
	<Type>default</Type>
	<FunctionIdentifier>
	  <NamespaceName>
	    <Pattern>android\.net</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Uri</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>parse</Pattern>
	  </FunctionName>
	</FunctionIdentifier>
	<Conditional>
	  <ConstantMatches argument="0">
	    <Pattern>^tel:</Pattern>
	  </ConstantMatches>
	</Conditional>
      </SemanticRule>

      <SemanticRule language="java" formatVersion="3.8">
	<RuleID>F22C1722-5810-4AAD-8DE8-E17C854F101D</RuleID>
	<Notes>Finds hardcode phone numbers format: tel: and 900</Notes>
	<VulnKingdom>Custom Android</VulnKingdom>
	<VulnCategory>Android Service Abuse</VulnCategory>
        <VulnSubcategory>Hardcoded Phone Number (900)</VulnSubcategory>
	<DefaultSeverity>5.0</DefaultSeverity>
	<Description>
	  <Abstract>
	  </Abstract>
	  <Explanation>
	  </Explanation>
	  <Recommendations>
	  </Recommendations>
	  <Tips>
	  </Tips>
	</Description>
	<Type>default</Type>
	<FunctionIdentifier>
	  <NamespaceName>
	    <Pattern>android\.net</Pattern>
	  </NamespaceName>
	  <ClassName>
	    <Pattern>Uri</Pattern>
	  </ClassName>
	  <FunctionName>
	    <Pattern>parse</Pattern>
	  </FunctionName>
	</FunctionIdentifier>
	<Conditional>
	  <ConstantMatches argument="0">
	    <Pattern>^tel:.*900</Pattern>
	  </ConstantMatches>
	</Conditional>
      </SemanticRule>
      
      <!-- =========================================================== -->
      <!-- =========== MAL: Retrieves Phone Identifiers ============== -->
      <!-- =========================================================== -->

      <StructuralRule formatVersion="3.8" language = "java">
	<RuleID>30D704E6-79DF-4992-A9C3-C1C5106B66BF</RuleID>
	<Notes>Code retrieves IMEI</Notes>
	<VulnKingdom>Custom Android</VulnKingdom>
	<VulnCategory>Android Exfiltration</VulnCategory>
        <VulnSubcategory>Retrieves IMEI</VulnSubcategory>
	<DefaultSeverity>5.0</DefaultSeverity>
	<Description>
	  <Abstract>
	  </Abstract>
	  <Explanation>
	  </Explanation>
	  <Recommendations>
	  </Recommendations>
	  <Tips>
	  </Tips>
	</Description>
	<Predicate>
	  <![CDATA[
	  FunctionCall c: c.function.name == "getDeviceId" and
	  c.function.enclosingClass.name == "android.telephony.TelephonyManager"
	  ]]>
	</Predicate>
      </StructuralRule>

      <StructuralRule formatVersion="3.8" language = "java">
	<RuleID>C6B53CB1-E782-4E62-A722-376FE7060397</RuleID>
	<Notes>Code retrieves IMSI</Notes>
	<VulnKingdom>Custom Android</VulnKingdom>
	<VulnCategory>Android Exfiltration</VulnCategory>
        <VulnSubcategory>Retrieves IMSI</VulnSubcategory>
	<DefaultSeverity>5.0</DefaultSeverity>
	<Description>
	  <Abstract>
	  </Abstract>
	  <Explanation>
	  </Explanation>
	  <Recommendations>
	  </Recommendations>
	  <Tips>
	  </Tips>
	</Description>
	<Predicate>
	  <![CDATA[
	  FunctionCall c: c.function.name == "getSubscriberId" and
	  c.function.enclosingClass.name == "android.telephony.TelephonyManager"
	  ]]>
	</Predicate>
      </StructuralRule>

      <StructuralRule formatVersion="3.8" language = "java">
	<RuleID>34CC0D71-128C-4894-9DE2-769DBB7C304E</RuleID>
	<Notes>Code retrieves ICC-ID</Notes>
	<VulnKingdom>Custom Android</VulnKingdom>
	<VulnCategory>Android Exfiltration</VulnCategory>
        <VulnSubcategory>Retrieves ICC-ID</VulnSubcategory>
	<DefaultSeverity>5.0</DefaultSeverity>
	<Description>
	  <Abstract>
	  </Abstract>
	  <Explanation>
	  </Explanation>
	  <Recommendations>
	  </Recommendations>
	  <Tips>
	  </Tips>
	</Description>
	<Predicate>
	  <![CDATA[
	  FunctionCall c: c.function.name == "getSimSerialNumber" and
	  c.function.enclosingClass.name == "android.telephony.TelephonyManager"
	  ]]>
	</Predicate>
      </StructuralRule>

      <StructuralRule formatVersion="3.8" language = "java">
	<RuleID>B6D3A998-A1D3-439B-8F4E-0D15C7D8D2B8</RuleID>
	<Notes>Code retrieves Phone Number</Notes>
	<VulnKingdom>Custom Android</VulnKingdom>
	<VulnCategory>Android Exfiltration</VulnCategory>
        <VulnSubcategory>Retrieves Phone Number</VulnSubcategory>
	<DefaultSeverity>5.0</DefaultSeverity>
	<Description>
	  <Abstract>
	  </Abstract>
	  <Explanation>
	  </Explanation>
	  <Recommendations>
	  </Recommendations>
	  <Tips>
	  </Tips>
	</Description>
	<Predicate>
	  <![CDATA[
	  FunctionCall c: c.function.name == "getLine1Number" and
	  c.function.enclosingClass.name == "android.telephony.TelephonyManager"
	  ]]>
	</Predicate>
      </StructuralRule>

      <!-- =========================================================== -->
      <!-- =========== MAL: Retrieves Location ======================= -->
      <!-- =========================================================== -->

      <StructuralRule formatVersion="3.8" language = "java">
	<RuleID>D85BC835-75B1-4E28-96B8-CD3A89593CF1</RuleID>
	<Notes>Code retrieves Location</Notes>
	<VulnKingdom>Custom Android</VulnKingdom>
	<VulnCategory>Android Exfiltration</VulnCategory>
        <VulnSubcategory>Retrieves Location (getLastKnownLocation)</VulnSubcategory>
	<DefaultSeverity>5.0</DefaultSeverity>
	<Description>
	  <Abstract>
	  </Abstract>
	  <Explanation>
	  </Explanation>
	  <Recommendations>
	  </Recommendations>
	  <Tips>
	  </Tips>
	</Description>
	<Predicate>
	  <![CDATA[
	  FunctionCall c: c.function.name == "getLastKnownLocation" and
	  c.function.enclosingClass.name == "android.location.LocationManager"
	  ]]>
	</Predicate>
      </StructuralRule>

      <StructuralRule formatVersion="3.8" language = "java">
	<RuleID>3A5D02C4-B0B2-4576-890A-F4DD842A1A97</RuleID>
	<Notes>Code retrieves Location</Notes>
	<VulnKingdom>Custom Android</VulnKingdom>
	<VulnCategory>Android Exfiltration</VulnCategory>
        <VulnSubcategory>Retrieves Location (requestLocationUpdates)</VulnSubcategory>
	<DefaultSeverity>5.0</DefaultSeverity>
	<Description>
	  <Abstract>
	  </Abstract>
	  <Explanation>
	  </Explanation>
	  <Recommendations>
	  </Recommendations>
	  <Tips>
	  </Tips>
	</Description>
	<Predicate>
	  <![CDATA[
	  FunctionCall c: c.function.name == "requestLocationUpdates" and
	  c.function.enclosingClass.name == "android.location.LocationManager"
	  ]]>
	</Predicate>
      </StructuralRule>

      <StructuralRule formatVersion="3.8" language = "java">
	<RuleID>94A43DC7-1B50-457D-84D6-CA27ED823AF0</RuleID>
	<Notes>Code retrieves Location</Notes>
	<VulnKingdom>Custom Android</VulnKingdom>
	<VulnCategory>Android Exfiltration</VulnCategory>
        <VulnSubcategory>Retrieves Location (LocationListener)</VulnSubcategory>
	<DefaultSeverity>5.0</DefaultSeverity>
	<Description>
	  <Abstract>
	  </Abstract>
	  <Explanation>
	  </Explanation>
	  <Recommendations>
	  </Recommendations>
	  <Tips>
	  </Tips>
	</Description>
	<Predicate>
	  <![CDATA[
	  Function f: f.name == "onLocationChanged" and
	  f.enclosingClass.supers contains 
	  [ Class c : c.name == "android.location.LocationListener" ]
	  ]]>
	</Predicate>
      </StructuralRule>

      <!-- =========================================================== -->
      <!-- =========== MAL: Retrieves Installed Applications ========= -->
      <!-- =========================================================== -->

      <StructuralRule formatVersion="3.8" language = "java">
	<RuleID>033370F4-ADEF-4DF4-99EA-C498B5EEEB02</RuleID>
	<Notes>Code retrieves info about installed applications</Notes>
	<VulnKingdom>Custom Android</VulnKingdom>
	<VulnCategory>Android Exfiltration</VulnCategory>
        <VulnSubcategory>Retrieves Installed Applications (get)</VulnSubcategory>
	<DefaultSeverity>5.0</DefaultSeverity>
	<Description>
	  <Abstract>
	  </Abstract>
	  <Explanation>
	  </Explanation>
	  <Recommendations>
	  </Recommendations>
	  <Tips>
	  </Tips>
	</Description>
	<Predicate>
	  <![CDATA[
	  FunctionCall c: 
	  ( c.function.name == "getInstalledApplications" or
	    c.function.name == "getInstalledPackages" or
	    c.function.name == "getPreferredPackages"
	  ) and
	  c.function.enclosingClass.name == "android.content.pm.PackageManager"
	  ]]>
	</Predicate>
      </StructuralRule>

      <StructuralRule formatVersion="3.8" language = "java">
	<RuleID>0F7BC9D7-3E15-41FB-BC2A-341DCC899FF6</RuleID>
	<Notes>Code retrieves info about installed applications</Notes>
	<VulnKingdom>Custom Android</VulnKingdom>
	<VulnCategory>Android Exfiltration</VulnCategory>
        <VulnSubcategory>Retrieves Installed Applications (query)</VulnSubcategory>
	<DefaultSeverity>5.0</DefaultSeverity>
	<Description>
	  <Abstract>
	  </Abstract>
	  <Explanation>
	  </Explanation>
	  <Recommendations>
	  </Recommendations>
	  <Tips>
	  </Tips>
	</Description>
	<Predicate>
	  <![CDATA[
	  FunctionCall c: 
	  ( c.function.name == "queryIntentActivities" or
	    c.function.name == "queryIntentServices" or
	    c.function.name == "queryBroadcastReceivers" or
	    c.function.name == "queryContentProviders"
	  ) and
	  c.function.enclosingClass.name == "android.content.pm.PackageManager"
	  ]]>
	</Predicate>
      </StructuralRule>

      <!-- =========================================================== -->
      <!-- =========== MAL: Deletes files in a loop ================== -->
      <!-- =========================================================== -->

      <!-- doesn't work yet
      <StructuralRule formatVersion="3.8" language = "java">
	<RuleID>B77AC964-CF5C-4766-8EE7-3CD8C475E48C</RuleID>
	<Notes>File.delete() in a loop</Notes>
	<VulnKingdom>Custom Android</VulnKingdom>
	<VulnCategory>Android Descructive</VulnCategory>
        <VulnSubcategory>Uses File.delete() in a loop</VulnSubcategory>
	<DefaultSeverity>5.0</DefaultSeverity>
	<Description>
	  <Abstract>
	  </Abstract>
	  <Explanation>
	  </Explanation>
	  <Recommendations>
	  </Recommendations>
	  <Tips>
	  </Tips>
	</Description>
	<Predicate>
	  <![CDATA[
	  FunctionCall c: c.function.name == "delete" and
	    c.function.enclosingClass.name == "java.io.File" and
	    c.function.enclosingStatement reachedBy
	    [ WhileStatement loop ]
	  ]]>
	</Predicate>
      </StructuralRule>
      -->

      <!-- =========================================================== -->
      <!-- =========== MAL: Random Suspicious behavior =============== -->
      <!-- =========================================================== -->

      <StructuralRule formatVersion="3.8" language = "java">
	<RuleID>C94B7C76-4A74-4CBF-924F-BD040D25BC36</RuleID>
	<Notes>Uses normal sockets</Notes>
	<VulnKingdom>Custom Android</VulnKingdom>
	<VulnCategory>Android Suspicious</VulnCategory>
        <VulnSubcategory>Uses Socket.connect() Directly</VulnSubcategory>
	<DefaultSeverity>5.0</DefaultSeverity>
	<Description>
	  <Abstract>
	  </Abstract>
	  <Explanation>
	  </Explanation>
	  <Recommendations>
	  </Recommendations>
	  <Tips>
	  </Tips>
	</Description>
	<Predicate>
	  <![CDATA[
	  FunctionCall c: 
	  c.function.name == "connect" and
	  c.function.enclosingClass.name == "java.net.Socket"
	  ]]>
	</Predicate>
      </StructuralRule>

      <StructuralRule formatVersion="3.8" language = "java">
	<RuleID>EDE3D4CC-106C-484C-802A-EDEBB73AB881</RuleID>
	<Notes>Uses normal sockets</Notes>
	<VulnKingdom>Custom Android</VulnKingdom>
	<VulnCategory>Android Suspicious</VulnCategory>
        <VulnSubcategory>Uses new Socket(InetAddress|String) Directly</VulnSubcategory>
	<DefaultSeverity>5.0</DefaultSeverity>
	<Description>
	  <Abstract>
	  </Abstract>
	  <Explanation>
	  </Explanation>
	  <Recommendations>
	  </Recommendations>
	  <Tips>
	  </Tips>
	</Description>
	<Predicate>
	  <![CDATA[
	  FunctionCall c: 
	  c.function.enclosingClass.name == "java.net.Socket" and
	  c.function.constructor and
	  ( c.function.parameterTypes[0] == T"java.net.InetAddress" or
	    c.function.parameterTypes[0] == T"java.lang.String" )
	  ]]>
	</Predicate>
      </StructuralRule>
    
    </RuleDefinitions>
  </Rules>
</RulePack>
