在不可信賴的環境中執行 JDBC 數據庫操作的 Applet 會危及數據庫憑證安全。
默認情況下,允許 Java Applet 將數據庫連接打開回它們從其下載的服務器。在可信賴的環境中,這是可接受的;然而,在不可信賴的環境中,攻擊者可能會使用 Applet 查找數據庫憑證,并最終獲得對數據庫的直接訪問。
例 1:以下代碼顯示在 applet 中使用的硬編碼的數據庫密碼。
public class CustomerServiceApplet extends JApplet
{
public void paint(Graphics g)
{
...
conn = DriverManager.getConnection ("jdbc:mysql://db.example.com/customerDB", "csr", "p4ssw0rd");
...
[1] Standards Mapping - Common Weakness Enumeration - (CWE) CWE ID 305
[2] JDBC Guide:Getting Started - Security Considerations Sun Microsystems, Inc.