Skip to content

Commit 4132b74

Browse files
committed
fix(security): pin Hugging Face model revisions
1 parent faca7f4 commit 4132b74

2 files changed

Lines changed: 32 additions & 4 deletions

File tree

StabilityMatrix.Core/Helper/RemoteModels.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ private static RemoteResource ControlNetCommon(string path, string sha256)
199199
[
200200
new()
201201
{
202-
Url = new Uri("https://huggingface.co/Bingsu/adetailer/resolve/main/face_yolov8m.pt"),
202+
Url = new Uri("https://huggingface.co/Bingsu/adetailer/resolve/b0a075fd35454c86bb453a1ca06b29ffee704c20/face_yolov8m.pt"),
203203
HashSha256 = "f02b8a23e6f12bd2c1b1f6714f66f984c728fa41ed749d033e7d6dea511ef70c",
204204
InfoUrl = new Uri("https://huggingface.co/Bingsu/adetailer"),
205205
Author = "Bingsu",
@@ -212,7 +212,7 @@ private static RemoteResource ControlNetCommon(string path, string sha256)
212212
},
213213
new()
214214
{
215-
Url = new Uri("https://huggingface.co/Bingsu/adetailer/resolve/main/hand_yolov8s.pt"),
215+
Url = new Uri("https://huggingface.co/Bingsu/adetailer/resolve/b0a075fd35454c86bb453a1ca06b29ffee704c20/hand_yolov8s.pt"),
216216
HashSha256 = "5c4faf8d17286ace2c3d3346c6d0d4a0c8d62404955263a7ae95c1dd7eb877af",
217217
InfoUrl = new Uri("https://huggingface.co/Bingsu/adetailer"),
218218
Author = "Bingsu",
@@ -225,7 +225,7 @@ private static RemoteResource ControlNetCommon(string path, string sha256)
225225
},
226226
new()
227227
{
228-
Url = new Uri("https://huggingface.co/Bingsu/adetailer/resolve/main/person_yolov8m-seg.pt"),
228+
Url = new Uri("https://huggingface.co/Bingsu/adetailer/resolve/b0a075fd35454c86bb453a1ca06b29ffee704c20/person_yolov8m-seg.pt"),
229229
HashSha256 = "9d881ec50b831f546e37977081b18f4e3bf65664aec163f97a311b0955499795",
230230
InfoUrl = new Uri("https://huggingface.co/Bingsu/adetailer"),
231231
Author = "Bingsu",
@@ -238,7 +238,7 @@ private static RemoteResource ControlNetCommon(string path, string sha256)
238238
},
239239
new()
240240
{
241-
Url = new Uri("https://huggingface.co/Bingsu/adetailer/resolve/main/person_yolov8s-seg.pt"),
241+
Url = new Uri("https://huggingface.co/Bingsu/adetailer/resolve/b0a075fd35454c86bb453a1ca06b29ffee704c20/person_yolov8s-seg.pt"),
242242
HashSha256 = "b5684835e79fd8b805459e0f7a0f9daa437e421cb4a214fff45ec4ac61767ef9",
243243
InfoUrl = new Uri("https://huggingface.co/Bingsu/adetailer"),
244244
Author = "Bingsu",
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using StabilityMatrix.Core.Helper;
2+
3+
namespace StabilityMatrix.Tests.Core;
4+
5+
public class RemoteModelsTests
6+
{
7+
[Fact]
8+
public void ExecutableHuggingFaceModelsUsePinnedRevisions()
9+
{
10+
var executableExtensions = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
11+
{
12+
".bin",
13+
".ckpt",
14+
".pt",
15+
".pth",
16+
};
17+
18+
var unpinnedModels = RemoteModels
19+
.UltralyticsModelFiles
20+
.Where(model => model.DownloadableResource?.Url.Host == "huggingface.co")
21+
.Where(model => executableExtensions.Contains(Path.GetExtension(model.DownloadableResource!.Value.Url.AbsolutePath)))
22+
.Where(model => model.DownloadableResource!.Value.Url.AbsolutePath.Contains("/resolve/main/", StringComparison.Ordinal))
23+
.Select(model => model.DownloadableResource!.Value.Url)
24+
.ToArray();
25+
26+
Assert.Empty(unpinnedModels);
27+
}
28+
}

0 commit comments

Comments
 (0)