{"record":{"id":"5369b65587e198fc","repo":"spinnaker/spinnaker","slug":"found-getter-for-requested-s-but-rejected-due-to","errorCode":null,"errorMessage":"found getter for requested %s but rejected due to return type %s","messagePattern":"found getter for requested (.+?) but rejected due to return type (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"kork/kork-expressions/src/main/java/com/netflix/spinnaker/kork/expressions/allowlist/FilteredPropertyAccessor.java","lineNumber":40,"sourceCode":"import java.lang.reflect.Method;\nimport org.springframework.expression.spel.support.ReflectivePropertyAccessor;\n\npublic class FilteredPropertyAccessor extends ReflectivePropertyAccessor {\n  private final ReturnTypeRestrictor returnTypeRestrictor;\n\n  public FilteredPropertyAccessor(ReturnTypeRestrictor returnTypeRestrictor) {\n    this.returnTypeRestrictor = returnTypeRestrictor;\n  }\n\n  @Override\n  protected Method findGetterForProperty(\n      String propertyName, Class<?> clazz, boolean mustBeStatic) {\n    Method getter = super.findGetterForProperty(propertyName, clazz, mustBeStatic);\n    if (getter == null) {\n      throw new IllegalArgumentException(\n          format(\"requested getter %s not found on type %s\", propertyName, clazz));\n    } else if (!returnTypeRestrictor.supports(getter.getReturnType())) {\n      throw new IllegalArgumentException(\n          format(\n              \"found getter for requested %s but rejected due to return type %s\",\n              propertyName, getter.getReturnType()));\n    }\n    return getter;\n  }\n\n  @Override\n  protected Field findField(String name, Class<?> clazz, boolean mustBeStatic) {\n    Field field = super.findField(name, clazz, mustBeStatic);\n    if (field == null) {\n      throw new IllegalArgumentException(\n          format(\"requested field %s not found on type %s\", name, clazz));\n    } else if (!returnTypeRestrictor.supports(field.getType())) {\n      throw new IllegalArgumentException(\n          format(\"found field %s but rejected due to unsupported type %s\", name, clazz));\n    }\n    return field;","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/spinnaker/spinnaker/blob/1d4a5d0f6d10d0232b1af077decd559b68a94a5e/kork/kork-expressions/src/main/java/com/netflix/spinnaker/kork/expressions/allowlist/FilteredPropertyAccessor.java#L22-L58","documentation":"The second check in FilteredPropertyAccessor.findGetterForProperty: when a getter IS found for the property, its return type is validated against the configured returnTypeRestrictor. If the getter's return type is not supported by the allowlist, the accessor rejects it with this IllegalArgumentException, preventing expressions from reading properties of disallowed types. This is a security guard limiting what data SpEL expressions may traverse.","triggerScenarios":"A pipeline expression reads a property whose getter exists but whose return type (e.g. a runtime Class, ClassLoader, ProcessBuilder, or another non-allowlisted type) is rejected by the returnTypeRestrictor — commonly seen when probing for type-confusion/gadget properties under the expression allowlist.","commonSituations":"Expressions accidentally referencing sensitive properties (e.g. .class, runtime, systemProperties) which the allowlist blocks; legitimate properties returning types not yet allowlisted in configuration; upgrading code so a getter's return type changed to a restricted type.","solutions":["Change the expression to avoid accessing the restricted-type property","If the property is legitimately needed, extend the returnTypeRestrictor allowlist configuration to permit its return type","Return a simpler/allowed type (String, Number, primitives) from the getter if you control the class","Check service expression allowlist config to confirm which return types are permitted"],"exampleFix":"// before\n${instance.javaClass.classLoader} // getter returns Class/ClassLoader, rejected by restrictor\n// after\n${instance.name} // access only allowlisted-typed properties","handlingStrategy":"try-catch","validationCode":"java.lang.reflect.Method g = target.getClass().getMethod(\"get\" + capitalize(prop));\nClass<?> rt = g.getReturnType();\n// ensure rt is in the configured allowlist before evaluating the expression","typeGuard":"boolean returnTypeAllowed(Method getter, ReturnerTypeRestrictor r) { return r.supports(getter.getReturnType()); }","tryCatchPattern":"try {\n  Object v = expression.getValue(evalContext);\n} catch (SpelEvaluationException e) {\n  if (e.getCause() instanceof IllegalArgumentException && e.getCause().getMessage().contains(\"rejected due to return type\")) {\n    log.warn(\"Property blocked by expression allowlist: \" + e.getCause().getMessage());\n  }\n}","preventionTips":["Keep expression authoring restricted to allowlisted property types (String, Number, primitives)","Never traverse .class, classLoader, runtime or similar gadget properties in expressions","When adding getters that expressions must read, verify the return type is in the returnTypeRestrictor configuration"],"tags":["spel","expressions","security","allowlist"],"backgroundTag":"invalid-argument-value","analyzedSha":"1d4a5d0f6d10d0232b1af077decd559b68a94a5e","analyzedAt":"2026-09-10T14:13:07.222Z","contentChangedAt":"2026-09-10T14:13:07.222Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}