Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uIh92-009kQF-Ns for pgsql-bugs@arkaria.postgresql.org; Sat, 24 May 2025 05:10:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uIh91-009JZn-9f for pgsql-bugs@arkaria.postgresql.org; Sat, 24 May 2025 05:10:02 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uIh91-009JZf-13 for pgsql-bugs@lists.postgresql.org; Sat, 24 May 2025 05:10:02 +0000 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uIh8w-000gcL-0K for pgsql-bugs@lists.postgresql.org; Sat, 24 May 2025 05:10:02 +0000 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-44a57d08bbfso2891675e9.2 for ; Fri, 23 May 2025 22:09:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1748063397; x=1748668197; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=+Ve/u+fYueo1+Av8WBo2MdqR8clts8AQaN4sP95dT7g=; b=IN6c1/yki+Nt1bB+Ql9arm3hESngn+zc9HVqJfpQCr+BwNrJzHMzpKVHxbv4sCJUhA bPKlK7579tw5krHoHY+dkqjI+tAn59aUNzRciA416sPKiyzBhI+M/LrlBFW/K9Y5WPPg xk/4/lzqRes+uLhP0MRZWLSo5v98MBuNytmtdEeqKD/w0Wmw/iCdgHLK+gFyj6GUMpvA 0s8mcGoW9lJrmUEpybin3Fsc+16vnvfeKALdRj8SttSqnNv0Dq8KlI348v7FaIxfp9Px q2aiSeZgB9GTWHAgia8e065Ay20KxR8exEBU34Hzw/pe8GELuEIpvldmZdaBfucIBknu R4Mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748063397; x=1748668197; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=+Ve/u+fYueo1+Av8WBo2MdqR8clts8AQaN4sP95dT7g=; b=FWM+Z+wmBZNVGoYM3jbM0SJF7QBDrY3y1126bAooiNu7XNuwk2YWDk23k8OeAsUeh5 gYFraaWUCJfSQaonXZHvfhS1BiW+lCyyDJUwEgsf66qJSf4/5Zj9dBZ89xBQnsVIwVEB zUPtmmnp0BVeCCBMH7izQUexo2aI2oIKYT0SmGcPiXzoDntxAqDtGWPDNUlbncDRCsmg ewdKWlpOwMa6iaIly7iw4jx7RNsQN2EyZ7teRjH99/Y5pDXhTmP2S0Rac7nzQ4WsS0Wz QhCPtPVFJPw5pnRY8q5PrZF6eJsSrcSh5cpjTEotbB1mpjxgG9vvXSapQr/rANkoFYuZ Ypcw== X-Forwarded-Encrypted: i=1; AJvYcCXxB4kCFJG4oYcsRsMsrPhmqrcFIRLtxMMJoiJjGHg+tPBGCF3TxbX7NgRMRSvB8wSm7h4WbDdAQA/w@lists.postgresql.org X-Gm-Message-State: AOJu0YyCzXaYcHsOicv5s6BgoTgt6iE93wLnYIXhGGhgaRXfbpR+y8iG u8SAk0Ww9F9v+mQl3fGW5dJh0sKDaINlM8bEnBhEd8AraDfl8eRlKvrWHQafRlKCHdY= X-Gm-Gg: ASbGncuXASNNoEtMsKdxFiDmqxCNjfe4lJp/uPGEMxie41HXvOORh9G5L3yy+J7fWD3 6xE8kDlemivWpkENHSzRLKddn1DxvYpQ/sMBol3D4tdNeAJxYq1EZlDdZSg4t76iUOe8M0VMPOi yTVfDnScgsunTww4LhPyl2WmWV5ncmSqv7pTrsM4p/3qJXIN9s5X7v1WOihua6Nz/AGpFGw8wVV 5SLGEDeviA3ZMBFnTSysSIiDpv6JRyuVT7xIooDWNoRLj7+/DDAKAVaNVW6W4Be4VoYYYUbVv2Z JLsZco+r60q8tLvF50Slqa7T/iojemN55+pvzcRf7GqrRAG0Nn+DnQJ+48K49oUbhB+Xs26sH+A lbN3y4Q== X-Google-Smtp-Source: AGHT+IFhIDodYTeLH7eceXmaBTbMC8JX82zpGdEXIuKJyhNhnoM8LnXBMatHnGLf+CJqQkO/smaTWg== X-Received: by 2002:a05:600c:5120:b0:43d:683:8cb2 with SMTP id 5b1f17b1804b1-44c94374ed0mr11832525e9.14.1748063397216; Fri, 23 May 2025 22:09:57 -0700 (PDT) Received: from laurenz.albe-K4N0CV00F97414D ([2001:871:255:52d3:3ac8:61ab:b634:342]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-447f7bae3b9sm161990505e9.33.2025.05.23.22.09.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 May 2025 22:09:56 -0700 (PDT) Message-ID: Subject: Re: BUG #18936: Trigger enable users to modify the tables which hedoesn't have privilege From: Laurenz Albe To: ZhangChi <798604270@qq.com>, pgsql-bugs Date: Sat, 24 May 2025 07:09:56 +0200 In-Reply-To: References: <18936-197af1cbbd49156f@postgresql.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.56.1 (3.56.1-1.fc42) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sat, 2025-05-24 at 11:06 +0800, ZhangChi wrote: > However, it is common in some database servers for an attacker to gain mi= nimal privileges > on a single table within a target database. For instance, when registerin= g an account on a > service, the system might grant the user access to a dedicated table. Usi= ng the TRIGGER > mechanism as I showed, such an attacker could then delete or exfiltrate d= ata from other > tables beyond their authorized access. Notably, this attack doesn't requi= re superuser > privileges - only access to the two relevant tables. >=20 > Permitting users to create triggers that can affect tables beyond their p= rivilege scope > appears to be a problematic design choice. Such triggers may be inadverte= ntly executed > by privileged users without their knowledge, creating potential security = vulnerabilities. The effects of a trigger are limited by the permissions of the executing us= er or (in the case of SECURITY DEFINER) the owner of the trigger function. Therefore, as I said, it is commendable never to do DML as a superuser. There are cases where superusers perform DML, like restoring a pg_dump. PostgreSQL takes great care that nothing can go wrong in these cases. Yours, Laurenz Albe