Summary: Right now, taint gets lost if it flows into a constructor or procedure whose implementation is missing. Since the core Java (e.g., String) and Android classes (e.g, Intent) are among these, this is bad. We could handle this by writing a bunch of models instead, but that would be a lot of work (plus we may still miss cases). Reviewed By: jvillard Differential Revision: D4051591 fbshipit-source-id: 65851c8master
							parent
							
								
									31d886bede
								
							
						
					
					
						commit
						319463b3bc
					
				| @ -1,35 +0,0 @@ | |||||||
| /* |  | ||||||
|  * Copyright (c) 2016 - present Facebook, Inc. |  | ||||||
|  * All rights reserved. |  | ||||||
|  * |  | ||||||
|  * This source code is licensed under the BSD style license found in the |  | ||||||
|  * LICENSE file in the root directory of this source tree. An additional grant |  | ||||||
|  * of patent rights can be found in the PATENTS file in the same directory. |  | ||||||
|  */ |  | ||||||
| 
 |  | ||||||
| package codetoanalyze.java.quandary; |  | ||||||
| 
 |  | ||||||
| import com.facebook.infer.builtins.InferTaint; |  | ||||||
| 
 |  | ||||||
| /** testing how the analysis handles strings and string manipulation functions */ |  | ||||||
| 
 |  | ||||||
| public class Strings { |  | ||||||
| 
 |  | ||||||
|   static class Wrapper { |  | ||||||
|     Object f; |  | ||||||
|   } |  | ||||||
| 
 |  | ||||||
|   static void valueOfStringBad() { |  | ||||||
|     Object source = InferTaint.inferSecretSource(); |  | ||||||
|     String stringSource = String.valueOf(source); |  | ||||||
|     InferTaint.inferSensitiveSink(stringSource); |  | ||||||
|   } |  | ||||||
| 
 |  | ||||||
|   static void valueOfStringWrapperBad() { |  | ||||||
|     Wrapper w = new Wrapper(); |  | ||||||
|     w.f = InferTaint.inferSecretSource(); |  | ||||||
|     String stringSource = String.valueOf(w.f); |  | ||||||
|     InferTaint.inferSensitiveSink(stringSource); |  | ||||||
|   } |  | ||||||
| 
 |  | ||||||
| } |  | ||||||
| @ -0,0 +1,46 @@ | |||||||
|  | /* | ||||||
|  |  * Copyright (c) 2016 - present Facebook, Inc. | ||||||
|  |  * All rights reserved. | ||||||
|  |  * | ||||||
|  |  * This source code is licensed under the BSD style license found in the | ||||||
|  |  * LICENSE file in the root directory of this source tree. An additional grant | ||||||
|  |  * of patent rights can be found in the PATENTS file in the same directory. | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | package codetoanalyze.java.quandary; | ||||||
|  | 
 | ||||||
|  | import com.facebook.infer.builtins.InferTaint; | ||||||
|  | 
 | ||||||
|  | /** testing how the analysis handles missing/unknown code */ | ||||||
|  | 
 | ||||||
|  | public class UnknownCode { | ||||||
|  | 
 | ||||||
|  |   native static Object id(Object o); | ||||||
|  | 
 | ||||||
|  |   public UnknownCode() {} | ||||||
|  | 
 | ||||||
|  |   static void propagateViaUnknownCodeBad() { | ||||||
|  |     Object source = InferTaint.inferSecretSource(); | ||||||
|  |     Object launderedSource = id(source); | ||||||
|  |     InferTaint.inferSensitiveSink(launderedSource); | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   static void propagateViaUnknownConstructorBad() { | ||||||
|  |     String source = (String) InferTaint.inferSecretSource(); | ||||||
|  |     // we don't analyze the code for the core Java libraries, so this constructor will be unknown
 | ||||||
|  |     String unknownConstructor = new String(source); | ||||||
|  |     InferTaint.inferSensitiveSink(unknownConstructor); | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   static void propagateViaUnknownConstructorOk() { | ||||||
|  |     String unknownConstructor = new String(""); | ||||||
|  |     InferTaint.inferSensitiveSink(unknownConstructor); | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   static void propagateViaUnknownCodeOk() { | ||||||
|  |     Object notASource = new UnknownCode(); | ||||||
|  |     Object launderedSource = id(notASource); | ||||||
|  |     InferTaint.inferSensitiveSink(launderedSource); | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  | } | ||||||
					Loading…
					
					
				
		Reference in new issue