java代码审计关键字讲解
fastjson反序列化 json.parseObject JSONObject.parseObject@RequestBody
其他反序列化 request.getinputstream ObjectInputStream .readObject() deserialize Serialize@RequestBody ObjectInputStream.readUnshared XMLDecoder.readObject Yaml.load XStream.fromXML ObjectMapper.readValue
文件上传
命令执行 Runtime.getRuntime().execcase shell ShellProcessor processor
SQL注入 order by = '"+ query(queryList) like "% .call ${
文件下载
越权(信息泄露) 直接看业务逻辑,看有无对登陆/权限的校验
目录遍历/ssrf
文件包含(jsp文件)
XXE
引用的接口: javax.xml.parsers.DocumentBuilder javax.xml.stream.XMLInputFactoryr org.jdom.input.SAXBuilder org.jdom2.input.SAXBuilder javax.xml.parsers.SAXParser org.dom4j.io.SAXReader org.xml.sax.XMLReader javax.xml.transform.sax.SAXSource javax.xml.transform.TransformerFactory javax.xml.transform.sax.SAXTransformerFactory javax.xml.validation.SchemaFactory javax.xml.bind.Unmarshaller javax.xml.xpath.XPathExpression
修复写法: javax.xml.parsers.DocumentBuilder
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setAttribute("http://apache.org/xml/features/disallow-doctype-decl" , true ); dbf.setAttribute("http://xml.org/sax/features/external-general-entities" , false ); dbf.setAttribute("http://xml.org/sax/features/external-parameter-entities" , false ); dbf.setAttribute("http://apache.org/xml/features/nonvalidating/load-external-dtd" , false ); dbf.setAttribute(XMLConstants.FEATURE_SECURE_PROCESSING, true ); dbf.setExpandEntityReferences(false ); DocumentBuilder db = dbf.newDocumentBuilder();
XMLInputFactory xif = XMLInputFactory.newInstance(); xif.setProperty(XMLInputFactory.SUPPORT_DTD, false ); xif.setProperty("javax.xml.stream.isSupportingExternalEntities" , false ); XMLStreamReader reader = xif.createXMLStreamReader(new FileInputStream(new File(path))); org.jdom.input.SAXBuilder SAXBuilder saxBuilder = new SAXBuilder(); saxBuilder.setFeature("http://apache.org/xml/features/disallow-doctype-decl" , true ); saxBuilder.setFeature("http://xml.org/sax/features/external-general-entities" , false ); saxBuilder.setFeature("http://xml.org/sax/features/external-parameter-entities" , false ); org.jdom2.Document build = saxBuilder.build(new File(path));
javax.xml.parsers.SAXParser
SAXParserFactory spf =SAXParserFactory.newInstance(); spf.setFeature("http://apache.org/xml/features/disallow-doctype-decl" , true ); spf.setFeature("http://xml.org/sax/features/external-general-entities" , false ); spf.setFeature("http://xml.org/sax/features/external-parameter-entities" , false ); SAXParser parser =spf.newSAXParser(); MyDefaultHandler myHandler = new MyDefaultHandler();
org.xml.sax.XMLReader
FileReader fileReader = new FileReader(path); XMLReader parser = XMLReaderFactory.createXMLReader(); parser.setFeature("http://apache.org/xml/features/disallow-doctype-decl" , true ); parser.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd" , false ); parser.setFeature("http://xml.org/sax/features/external-general-entities" , false ); parser.setFeature("http://xml.org/sax/features/external-parameter-entities" , false );
xml反序列化写法 public void XMLDecoder (String path) {try { File file = new File(path); FileInputStream fis = new FileInputStream(file); BufferedInputStream bis = new BufferedInputStream(fis); XMLDecoder xd = new XMLDecoder(bis); xd.readObject(); xd.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } }
业务逻辑漏洞 走if的时候根据判断status是否等于true来进行流程,比如status/resultCode==0
时允许进行下一步 示例:
if ("0" .equals(resultCode)) { }
密码硬编码
springmvc业务逻辑
tapestry框架业务逻辑
实现
CORS
配置文件
接口
声明: 本文章用于学习交流,严禁用于非法操作,出现后果一切自行承担,阅读此文章表示你已同意本声明。 Disclaimer: This article is for study and communication. It is strictly forbidden to use it for illegal operations. All consequences shall be borne by yourself. Reading this article means that you have agreed to this statement.