Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.
C# aspnet-corecsharpdockerdotnetecommerceecommerce-platformmongodbmulti-storemulti-vendornosqlonline-shopshoppingcart
Harden BaseProductController against CodeQL CSRF finding; gitignore docs/superpowers/
KrzysztofPajake4b2ef1525c7
diff --git a/.gitignore b/.gitignoreindex 5f318b6be..faea5c658 100644--- a/.gitignore+++ b/.gitignore@@ -381,3 +381,4 @@ src/Web/Grand.Web.Store/Plugins/*src/Web/Grand.Web.Store/Modules/*src/Web/Grand.Web.Store/App_Data/DataProtectionKeys/*src/Web/Grand.Web.Store/wwwroot/assets/images/thumbs/*.**.worktrees/+docs/superpowers/diff --git a/docs/superpowers/specs/2026-08-17-arch001-phase2-view-consolidation-design.md b/docs/superpowers/specs/2026-08-17-arch001-phase2-view-consolidation-design.mdindex 2e85bd298..48d5ec078 100644--- a/docs/superpowers/specs/2026-08-17-arch001-phase2-view-consolidation-design.md+++ b/docs/superpowers/specs/2026-08-17-arch001-phase2-view-consolidation-design.md@@ -600,3 +600,35 @@ speculatively ahead of a caller, which is what happened here.`dotnet build GrandNode.sln` clean. `Grand.Web.Admin.Tests`/`Grand.Web.Store.Tests`/`Grand.Web.Vendor.Tests`: 419/33/8 (down 2 from the removed `ApplyScope` tests), all green.++## 9. CodeQL: "missing CSRF token validation" on `BaseProductController.cs` (addendum, 2026-08-19)++### Investigation++CodeQL flagged `BaseProductController.cs`'s `[HttpPost]` actions as missing antiforgery validation.+Checked: `BaseProductController` is `abstract` (never directly routable) and extends+`Grand.Web.Common.Controllers.BaseController`, which carries no antiforgery attribute. Its three+concrete subclasses (`Grand.Web.Admin`/`Grand.Web.Store`/`Grand.Web.Vendor`'s `ProductController`)+each already declare `[AutoValidateAntiforgeryToken]` at the class level - restated there since Phase+1 Task 11 explicitly because `BaseProductController` "can't inherit any single host's base controller"+(each host's own `BaseAdminController`/`BaseStoreController`/`BaseVendorController`, which normally+supplies it, differs by `[Area]`/`[Authorize*]`). ASP.NET Core resolves MVC filters from the full type+hierarchy of the concrete controller at request time, so every actual runtime endpoint (there are only+these three concrete subclasses - grep confirmed) is already protected. This is a static-analysis+false positive in the sense that no exploitable gap exists today - CodeQL's query doesn't follow an+attribute from a derived class in a different project back onto the base class where the actions are+textually defined.++### Fix++Added `[AutoValidateAntiforgeryToken]` directly to `BaseProductController` too. This changes no+runtime behavior (redundant with the three subclasses' own copies, and the base class was never+routable anyway), but removes a real fragility the false-positive investigation surfaced: protection+depended entirely on every current *and future* host subclass remembering to restate the attribute,+with nothing enforcing it at the point where the actions actually live. Also gives CodeQL's static+analysis something to see in the same file it flagged.++### Verification++`dotnet build GrandNode.sln` clean. `Grand.Web.Admin.Tests`/`Grand.Web.Store.Tests`/+`Grand.Web.Vendor.Tests`: 419/33/8, unchanged, all green.diff --git a/src/Web/Grand.Web.AdminShared/Controllers/BaseProductController.cs b/src/Web/Grand.Web.AdminShared/Controllers/BaseProductController.csindex 1b9756218..c55964107 100644--- a/src/Web/Grand.Web.AdminShared/Controllers/BaseProductController.cs+++ b/src/Web/Grand.Web.AdminShared/Controllers/BaseProductController.cs@@ -69,7 +69,17 @@ namespace Grand.Web.AdminShared.Controllers;// directly (Store has no distinct resource set), consistent with StoreAdminDataScope.ResourceKeyPrefix// returning "Admin".+// [AutoValidateAntiforgeryToken] is also restated on each of the three concrete host subclasses+// (Admin/Store/Vendor ProductController) - ASP.NET Core resolves filters from the full type hierarchy+// of the concrete controller at runtime, so those subclass-level attributes already protect every+// [HttpPost] action defined here. It's added here too so CodeQL's static analysis (which flagged this+// file directly - it doesn't follow the attribute from a derived class in a different project back+// onto the base class where the actions are textually defined) has something to see in the same file+// as the actions, and so a future host subclass that forgets to restate the attribute doesn't silently+// lose CSRF protection - BaseProductController itself is abstract and never directly routable, so this+// changes no runtime behavior today.[PermissionAuthorize(PermissionSystemName.Products)]+[AutoValidateAntiforgeryToken]public abstract class BaseProductController(IProductViewModelService productViewModelService,IProductService productService,